13.1.32 DROP TABLE Statement语句

DROP [TEMPORARY] TABLE [IF EXISTS]
tbl_name [, tbl_name] ...
    [RESTRICT | CASCADE]

DROP TABLE removes one or more tables. DROP TABLE删除一个或多个表。You must have the DROP privilege for each table.您必须具有每个表的DROP权限。

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 the TEMPORARY keyword. DROP TABLE导致隐式提交,除非与临时关键字一起使用。See Section 13.3.3, “Statements That Cause an Implicit Commit”.请参阅第13.3.3节,“导致隐式提交的语句”

Important重要

When a table is dropped, privileges granted specifically for the table are not automatically dropped. 删除表时,不会自动删除专门为该表授予的特权。They must be dropped manually. 必须手动删除它们。See Section 13.7.1.6, “GRANT Statement”.请参阅第13.7.1.6节,“GRANT语句”

If any tables named in the argument list do not exist, DROP TABLE behavior depends on whether the IF EXISTS clause is given:如果参数列表中命名的任何表不存在,则DROP TABLE行为取决于是否给定IF EXISTS子句:

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. IF EXISTS还可用于在数据字典中有条目但存储引擎没有管理表的异常情况下删除表。(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.)(例如,如果在从存储引擎中删除表之后但在删除数据字典条目之前发生异常服务器退出。)

The TEMPORARY keyword has the following effects:TEMPORARY关键字具有以下效果:

Including the TEMPORARY keyword is a good way to prevent accidentally dropping non-TEMPORARY tables.包含TEMPORARY关键字是防止意外删除非TEMPORARY表的好方法。

The RESTRICT and CASCADE keywords do nothing. RESTRICTCASCADE关键字不起任何作用。They are permitted to make porting easier from other database systems.它们允许更容易地从其他数据库系统进行移植。

DROP TABLE is not supported with all innodb_force_recovery settings. 并非所有innodb_force_recovery设置都支持DROP TABLESee Section 15.21.2, “Forcing InnoDB Recovery”.请参阅第15.21.2节,“强制InnoDB恢复”