4.7 DROP TABLE
When you no longer need a table, you can destroy it with the DROP TABLE statement:
DROP TABLE t;
In MySQL, a single DROP TABLE statement can name several tables to be dropped simultaneously:
DROP TABLE t1, t2, t3;
Normally, an error occurs if you attempt to drop a table that does not exist:
mysql> DROP TABLE no_such_table;
ERROR 1051: Unknown table 'no_such_table'
To prevent an error from occurring if a table does not exist when you attempt to drop it, add an IF EXISTS clause to the statement:
mysql> DROP TABLE IF EXISTS no_such_table;
If you drop a table by mistake, you must recover it from backups, so be careful. (This is the same principle as the one mentioned earlier for databases: If you drop a database, you cannot undo the action. A dropped database can only be recovered from your backups.)
|