2020-06-15
阅读量:
601
mysql怎么删除表中的数据?
Mysql 删除数据表有三种方式:
1、当你不再需要该表时, 用 drop;
2、当你仍要保留该表,但要删除所有记录时, 用 truncate;
3、当你要删除部分记录或者有可能会后悔的话, 用 delete。
删除程度可从强到弱如下排列:
1. drop table tb;
drop 是直接将表格删除,无法找回。例如删除 user 表:
drop table user;
2. truncate (table) tb;
truncate 是删除表中所有数据,但不能与where一起使用;
TRUNCATE TABLE user;
3. delete from tb (where);
delete 也是删除表中数据,但可以与where连用,删除特定行;
-- 删除表中所有数据
delete from user;
-- 删除指定行
delete from user where username ='Tom';






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论