mysql事務(ddl隱式提交)


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM