MySQL 删除数据表

用 DROP TABLE 删表,结构与数据一同消失。

Beginner
Key PointsDROP TABLE 删除表结构和全部数据,和 DROP DATABASE 一样不可逆。

基本语法

SQL
DROP TABLE users;
DROP TABLE IF EXISTS users;          -- 存在才删
DROP TABLE a, b;                     -- 一次删多张
Output
Query OK, 0 rows affected (0.02 sec)
Dropping a table referenced by a foreign key fails with Cannot delete or update a parent row. Drop the child first, or remove the FK constraint.

Friends & Partners