set autocommit=0 和 start transaction区别
相同之处
- set autocommit=0 是显示设置手动提交事务
- start transaction 是隐式的设置手动提交事务
不同之处
start transaction
To disable autocommit mode implicitly for a single series of statements, use the
START TRANSACTION
statement:
对于 start transaction 去手动提交事务,中间执行了多条 sql 语句后,当执行了 commit之后,手动事务就结束了
set autocommit=0
If
autocommit
mode is disabled within a session withSET autocommit = 0
, the session always has a transaction open. ACOMMIT
orROLLBACK
statement ends the current transaction and a new one starts.
对于 set autocommit=0 方式设置手动提交事务的,中间执行多条 sql 语句后, 当 执行了 commit 后, 会结束当前事务,并开启新的事务, 所以事务是没有结束的