mysql事務(ddl隱式提交)

DDL爲隱式提交若出如今begin與rollback之間,則會直接提交ddl以前的語句,以下:mysql

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不起做用sql

 [即便設置 autocommit爲false,依然沒法回滾]spa

mysql> show variables like 'autocommit';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit | OFF |
+---------------+-------+code

相關文章
相關標籤/搜索