Dear All,
How do I check for the existence of a table in a MySQL database, and if so, delete it?
Many thanks
Mark
Checking table existence before DROPping it
Moderator: General Moderators
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
You can use mysql_list_tables() and then see if its in the results, if it is then delete it:
Code: Select all
DROP TABLE `the_table_i_want_to_delete`- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
DROP TABLE Syntax wrote:DROP [TEMPORARY] TABLE [IF EXISTS]
tbl_name [, tbl_name] ...
[RESTRICT | CASCADE]