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 |
+---------------+-------+

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-07
  • 2021-11-19
  • 2022-01-20
  • 2022-02-09
  • 2022-02-09
猜你喜欢
  • 2021-09-28
  • 2021-11-06
  • 2021-09-10
  • 2021-08-28
  • 2022-01-29
  • 2021-12-29
相关资源
相似解决方案