一、更新

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 数据库名字;

到此这篇关于mysql更新,删除操作分享的文章就介绍到这了,更多相关mysql更新,删除内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!