zoukankan      html  css  js  c++  java
  • 默认InnoDB 是REPEATABLE READ.(重复读隔离)

    SQL:1992 事务隔离级别的术语,默认InnoDB 是REPEATABLE READ.(重复读隔离)

    对于MySQL的Innodb的默认事务隔离级别是重复读(repeatable read)。可以通过下面的命令查看:

    mysql> SELECT @@GLOBAL.tx_isolation, @@tx_isolation;
    +———————–+—————–+
    | @@GLOBAL.tx_isolation | @@tx_isolation |
    +———————–+—————–+
    | REPEATABLE-READ | REPEATABLE-READ |
    +———————–+—————–+
    1 row in set (0.00 sec)

    SESSION A:
    set autocommit=0;

    mysql> select * from t2;
    +——+
    | id |
    +——+
    | 99 |
    +——+
    1 row in set (0.00 sec)

    mysql> update t2 set id=100 where id=99;
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1 Changed: 1 Warnings: 0

    SESSION B:

    mysql> set autocommit=0;
    Query OK, 0 rows affected (0.00 sec)

    mysql> select * from t2;
    +——+
    | id |
    +——+
    | 99 |
    +——+
    1 row in set (0.01 sec)

    SESSION A: 执行commit

    SESSION B:
    mysql> select * from t2;
    +——+
    | id |
    +——+
    | 99 |
    +——+
    1 row in set (0.00 sec)

    Session A已经提交,还是看到数据不变,即可以重复读。

    SESSION B:

    mysql> commit;
    Query OK, 0 rows affected (0.00 sec)

    mysql> select * from t2;
    +——+
    | id |
    +——+
    | 100 |
    +——+
    1 row in set (0.00 sec)

    【说明】
    提交事务,看到最新数据

  • 相关阅读:
    赔了多少钱
    datatables使用
    Django开发汇总
    STF的DOCKER搭建
    ubuntu基本
    python 列表、元组、字典、字符串
    Appium环境搭建
    AppCrawler环境搭建
    TASK 总结
    python & jira
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351230.html
Copyright © 2011-2022 走看看