[英]MySQL: Does `DROP TABLE` completely remove the table or just the structure?
I am under the impression that the MySQL command DROP TABLE User
will just remove the data, columns, and relevant constraints. 我的印象是MySQL命令DROP TABLE User
将只删除数据,列和相关约束。 However, the table shell still exists. 但是,表shell仍然存在。 Is this correct? 它是否正确?
Using DROP TABLE
will remove the entire table and all records contained inside it. 使用DROP TABLE
将删除整个表及其中包含的所有记录。 If you want to retain the table structure but remove all data, then consider using TRUNCATE TABLE
. 如果要保留表结构但删除所有数据,请考虑使用TRUNCATE TABLE
。 Truncating a table is implemented by dropping the entire table and then recreating it. 截断表是通过删除整个表然后重新创建它来实现的。 This is faster than doing DELETE FROM yourTable
, which removes records one-by-one. 这比执行DELETE FROM yourTable
更快,后者DELETE FROM yourTable
删除记录。
After Drop Table
, the table will not exist anymore, so no data and no table definition(which you called 'table shell'); 在Drop Table
,该表将不再存在,因此没有数据也没有表定义(你称之为'table shell'); TRUNCATE TABLE
keep your table definition and delete all the data ,and reset table auto-increment as well, but be careful about TRUNCATE
if the table size is huge, it will expand your tablespace and not easy to shrink. TRUNCATE TABLE
保留你的表定义并删除所有数据,并重置表自动增量,但如果表大小很大,请注意TRUNCATE
,它会扩展你的表空间而不容易缩小。
As mysql manual on drop table says: 正如drop table上的mysql手册所说:
Be careful with this statement! 小心这个说法! It removes the table definition and all table data. 它删除表定义和所有表数据。
So, no shell (whatever that should mean) remains after dropping a table. 因此,在删除表之后,没有shell(无论应该是什么意思)。
What do you mean by table shell? 桌壳是什么意思?
From MqSQL dev site: 从MqSQL开发站点:
DROP TABLE removes one or more tables. DROP TABLE删除一个或多个表。 You must have the DROP privilege for each table. 您必须具有每个表的DROP特权。
Be careful with this statement! 小心这个说法! It removes the table definition and all table data. 它删除表定义和所有表数据。 For a partitioned table, it permanently removes the table definition, all its partitions, and all data stored in those partitions. 对于分区表,它会永久删除表定义,其所有分区以及存储在这些分区中的所有数据。 It also removes partition definitions associated with the dropped table. 它还会删除与已删除表关联的分区定义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.