mysql事务

xiaoxiao2021-02-28  102

默认的mysql运行在autocommit模式下,这就意味着,当你执行完一个更新时,MySQL 将立刻将更新存储到磁盘上。

如果设置mysql为非autocommit模式:

1、setautocommit = 0;

2、执行更新语句时,加上begin;

例:

begin;

update tab set colum = 1 where id = 1;

 执行完成后手动提交或回滚

commit;/rollback;

转载请注明原文地址: https://www.6miu.com/read-34223.html

最新回复(0)