DROP [TEMPORARY] TABLE [IF EXISTS] tbl_name [, tbl_name] ... [RESTRICT | CASCADE]
Be careful with this statement! It removes the table definition and all table data. For a partitioned table, it permanently removes the table definition, all its partitions, and all data stored in those partitions. It also removes partition definitions associated with the dropped table.
Dropping a table also drops any triggers for the table.
DROP TABLE causes an implicit
commit, except when used with the
keyword. See Section 13.3.3, “Statements That Cause an Implicit Commit”.
When a table is dropped, privileges granted specifically for the table are not automatically dropped. They must be dropped manually. See Section 22.214.171.124, “GRANT Syntax”.
If any tables named in the argument list do not exist, the statement fails with an error indicating by name which nonexisting tables it was unable to drop, and no changes are made.
IF EXISTS to prevent an error from
occurring for tables that do not exist. Instead of an error, a
NOTE is generated for each nonexistent table;
these notes can be displayed with
WARNINGS. See Section 126.96.36.199, “SHOW WARNINGS Syntax”.
IF EXISTS can also be useful for dropping
tables in unusual circumstances under which there is an entry in
the data dictionary but no table managed by the storage engine.
(For example, if an abnormal server exit occurs after removal of
the table from the storage engine but before removal of the data
TEMPORARY keyword has the following
The statement drops only
The statement does not cause an implicit commit.
No access rights are checked. A
TEMPORARYtable is visible only with the session that created it, so no check is necessary.
TEMPORARY is a good way to ensure that
you do not accidentally drop a non-
keywords do nothing. They are permitted to make porting easier
from other database systems.