zoukankan      html  css  js  c++  java
  • 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 |
    +---------------+-------+

  • 相关阅读:
    HDOJ 1877
    POJ 2210
    HDOJ 1230(火星A+B)
    大数想减
    HDU 2115
    HDOJ 1234
    HDOJ 3784
    HDOJ3782(xxx定理)
    C# 使用 Stopwatch 测量代码运行时间
    SQL返回当前天是星期几
  • 原文地址:https://www.cnblogs.com/Nora-F/p/11463293.html
Copyright © 2011-2022 走看看