DROP [TEMPORARY] TABLE [IF EXISTS] tbl_name [, tbl_name] ... [RESTRICT | CASCADE]
DROP TABLE removes one or more
tables. You must have the
privilege for each table. All table data and the table definition
are removed, so be
careful with this statement! If any of the tables named
in the argument list do not exist, MySQL returns an error
indicating by name which nonexisting tables it was unable to drop,
but it also drops all of the tables in the list that do exist.
When a table is dropped, user privileges on the table are not automatically dropped. See Section 18.104.22.168, “GRANT Syntax”.
For a partitioned table,
permanently removes the table definition, all of its partitions,
and all of the data which was stored in those partitions. It also
removes partition definitions associated with the dropped table.
Prior to MySQL 5.7.6,
removes partition definitions (
associated with the dropped table. As of MySQL 5.7.6, partition
.par) files are no longer
created. Instead, partition definitions are stored in the
internal data dictionary.
IF EXISTS to prevent an error from
occurring for tables that do not exist. A
is generated for each nonexistent table when using
EXISTS. See Section 22.214.171.124, “SHOW WARNINGS Syntax”.
IF EXISTS can be useful for dropping tables in
unusual circumstances under which there is an
.frm file 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
.frm file removal.)
permitted to make porting easier. In MySQL 5.7, they
DROP TABLE automatically commits
the current active transaction, unless you use the
TEMPORARY keyword has the following
The statement drops only
The statement does not end an ongoing transaction.
No access rights are checked. (A
TEMPORARYtable is visible only to 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-