3

#yyds干货盘点# 10 MySQL更新、删除

 2 years ago
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.
neoserver,ios ssh client

#yyds干货盘点# 10 MySQL更新、删除

原创

江下下啊 2022-03-03 08:21:12 博主文章分类:MySQL ©著作权

文章标签 表名 字段 数据 文章分类 MySQL 数据库 阅读数353

UPDATE 表名 SET 字段1 = 值1, 字段2 = 值2,... WHERE 条件;
把id为12所对应的名字改为老哈
update users SET name = '老哈' where id = 12;

#yyds干货盘点# 10 MySQL更新、删除_表名

通过​​DELETE​​可以删除表中的一条记录或者多条记录

DELETE FROM 表名 WHERE 条件;
删除id等于9所对应的数据
DELETE FROM users WHERE id = 9;

#yyds干货盘点# 10 MySQL更新、删除_数据_02

删除所有数据
DELETE FROM 表名;
TRUNCATE删除
TRUNCATE TABLE 表名;
DELETE和TRUNCATE区别
  • DELETE支持条件,TRUNCATE不支持条件
  • DELETE支持事务回滚,TRUNCATE不支持回滚
  • DELETE清理速度比TRUNCATE要慢
  • TRUNCATE自增值会初始化
DROP TABLE 表名1, 表名2, ...;
删除数据库
DROP DATABASE 数据库名字;
  • 收藏
  • 评论
  • 分享
  • 举报

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK