Doc Menu

DROP TABLE

This statement drops a table from the currently selected database. An error is returned if the table does not exist, unless the IF EXISTS modifier is used.

Synopsis

DropTableStmt:

DropTableStmt

TableOrTables:

TableOrTables

TableNameList:

TableNameList

Examples

mysql> CREATE TABLE t1 (a INT);
Query OK, 0 rows affected (0.11 sec)

mysql> DROP TABLE t1;
Query OK, 0 rows affected (0.22 sec)

mysql> DROP TABLE table_not_exists;
ERROR 1051 (42S02): Unknown table 'test.table_not_exists'
mysql> DROP TABLE IF EXISTS table_not_exists;
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE VIEW v1 AS SELECT 1;
Query OK, 0 rows affected (0.10 sec)

mysql> DROP TABLE v1;
Query OK, 0 rows affected (0.23 sec)

MySQL compatibility

  • Dropping a table with IF EXISTS does not return a warning when attempting to drop a table that does not exist. Issue #7867
  • Currently RESTRICT and CASCADE are only supported syntactically.

See also