3
#yyds干货盘点# 10 MySQL更新、删除
source link: https://blog.51cto.com/u_15173612/5066494
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
#yyds干货盘点# 10 MySQL更新、删除
原创UPDATE 表名 SET 字段1 = 值1, 字段2 = 值2,... WHERE 条件;
把id为12所对应的名字改为老哈
update users SET name = '老哈' where id = 12;
通过DELETE
可以删除表中的一条记录或者多条记录
DELETE FROM 表名 WHERE 条件;
删除id等于9所对应的数据
DELETE FROM users WHERE id = 9;
删除所有数据
DELETE FROM 表名;
TRUNCATE删除
TRUNCATE TABLE 表名;
DELETE和TRUNCATE区别
- DELETE支持条件,TRUNCATE不支持条件
- DELETE支持事务回滚,TRUNCATE不支持回滚
- DELETE清理速度比TRUNCATE要慢
- TRUNCATE自增值会初始化
DROP TABLE 表名1, 表名2, ...;
删除数据库
DROP DATABASE 数据库名字;
- 赞
- 收藏
- 评论
- 分享
- 举报
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK