DDL为隐式提交若出现在begin与rollback之间,则会直接提交ddl之前的语句,如下:
begin; select * from test; update test set add='25-933-733-123444' where ID=1;#未提交 delete fromorder where orderID=2;#已提交 truncate test;#已提交 select * from test;#已提交 drop table dbshards.aly_test;#已提交 show tables from dbshards like 'test';#已提交 create table test (orderID int);#已提交 insert into dbshards.aly_test (orderID) values (1),(2),(3),(4);#已提交 select * from dbshards.aly_test;#已提交 rollback;#无效
在遇到第一句ddl语句执行之后,已commit,导致最后的rollback不起作用
[即使设置 autocommit为false,依然无法回滚]
mysql> show variables like 'autocommit';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit | OFF |
+---------------+-------+