MySql refresher - way to remove a table

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_40657585/article/details/102412885

1.mysql delete tables in three ways

delete、drop、truncate。

Similarities and differences:

  • delete and truncate table to delete only data, without deleting the table structure, truncate can not be retrieved (will release the space occupied by the table).
  • drop delete the entire table, you can not be recovered.

2. Usage

  • Not only can delete the drop table, you can also delete the database.
drop 表名/数据库名
  • Truncate delete all the data in the table, but can not be used with where
truncate 表名;
  • delete can be used in conjunction with the where, delete particular row
#删除表中所有数据
delete from 表名;

#删除符合条件的表数据
delete from 表名 where 字段名=条件;

Speed, the general drop> truncate> delete

Guess you like

Origin blog.csdn.net/qq_40657585/article/details/102412885