PDF (A4) - 43.4Mb
Man Pages (TGZ) - 297.3Kb
Man Pages (Zip) - 402.5Kb
Info (Gzip) - 4.3Mb
Info (Zip) - 4.3Mb
MySQL Globalization
MySQL Information Schema
MySQL Installation Guide
Security in MySQL
Starting and Stopping MySQL
MySQL and Linux/Unix
MySQL and Windows
MySQL and macOS
MySQL and Solaris
Building MySQL from Source
MySQL Restrictions and Limitations
MySQL Partitioning
MySQL Tutorial
MySQL Performance Schema
MySQL Replication
Using the MySQL Yum Repository
MySQL NDB Cluster 8.0
DROP [TEMPORARY] TABLE [IF EXISTS]tbl_name [,tbl_name] ... [RESTRICT | CASCADE]DROP TABLE removes one or more tables. You must have theDROP privilege for each table.
Be careful with this statement! For each table, it removes the table definition and all table data. If the table is partitioned, the statement removes the table definition, all its partitions, all data stored in those partitions, and all 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 theTEMPORARY keyword. SeeSection 15.3.3, “Statements That Cause an Implicit Commit”.
When a table is dropped, privileges granted specifically for the table arenot automatically dropped. They must be dropped manually. SeeSection 15.7.1.6, “GRANT Statement”.
If any tables named in the argument list do not exist,DROP TABLE behavior depends on whether theIF EXISTS clause is given:
Without
IF EXISTS, the statement fails with an error indicating which nonexisting tables it was unable to drop, and no changes are made.With
IF EXISTS, no error occurs for nonexisting tables. The statement drops all named tables that do exist, and generates aNOTEdiagnostic for each nonexistent table. These notes can be displayed withSHOW WARNINGS. SeeSection 15.7.7.42, “SHOW WARNINGS Statement”.
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 dictionary entry.)
TheTEMPORARY keyword has the following effects:
The statement drops only
TEMPORARYtables.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.
Including theTEMPORARY keyword is a good way to prevent accidentally dropping non-TEMPORARY tables.
TheRESTRICT andCASCADE keywords do nothing. They are permitted to make porting easier from other database systems.
DROP TABLE is not supported with allinnodb_force_recovery settings. SeeSection 17.21.3, “Forcing InnoDB Recovery”.
PDF (A4) - 43.4Mb
Man Pages (TGZ) - 297.3Kb
Man Pages (Zip) - 402.5Kb
Info (Gzip) - 4.3Mb
Info (Zip) - 4.3Mb
MySQL Globalization
MySQL Information Schema
MySQL Installation Guide
Security in MySQL
Starting and Stopping MySQL
MySQL and Linux/Unix
MySQL and Windows
MySQL and macOS
MySQL and Solaris
Building MySQL from Source
MySQL Restrictions and Limitations
MySQL Partitioning
MySQL Tutorial
MySQL Performance Schema
MySQL Replication
Using the MySQL Yum Repository
MySQL NDB Cluster 8.0