drop table t1; truncate table t1; delete from t1; 区别?
1. Divided by function:
drop table t1;
①Delete all table data, delete the entire table segment (rm ibd) index and data, ②Delete
table definition (rm frm, delete columns, metadata will also be deleted)
truncate table t1;
Clear the data in the table segment and retain the table structure.
delete from t1;
delete data rows row by row, retaining the table structure.
2. Divide the
drop table t1 according to the nature ; it
is a physical deletion. Will free up disk space.
truncate table t1;
is a physical deletion, which will release disk space.
delete from t1;
is a logical deletion. Just mark for deletion and will not release space immediately, so disk fragmentation will occur
For more exciting content, please follow the WeChat public account to get