zoukankan      html  css  js  c++  java
  • mysql 幻读

     幻读(Phantom Read) 是指当用户读取某一范围的数据行时,B事务在该范围内插入了新行,当用户再读取该范围的数据行时,会发现有新的“幻影”行。InnoDB和Falcon存储引擎通 过多版本并发控制机制解决了幻读问题。

     http://bbs.csdn.net/topics/360050896

    http://narcissusoyf.iteye.com/blog/1637309

    http://hudeyong926.iteye.com/blog/1490687

    http://imysql.cn/2008_07_10_innodb_tx_isolation_and_lock_mode

    http://www.cnblogs.com/zhaoyl/p/4121010.html

    A事务读取了B事务已经提交的新增数据,此时 A 还没有提交,当前提交后,也就看到了

    A事务

    mysql> select * from test;
    +----+----+
    | a | b |
    +----+----+
    | 14 | 14 |
    | 16 | 16 |
    | 10 | 20 |
    | 31 | 31 |
    | 33 | 33 |
    | 38 | 38 |
    | 50 | 60 |
    | 70 | 70 |
    +----+----+
    8 rows in set (0.00 sec)

    事务B

    mysql> insert into test (a,b) values(80,80);
    Query OK, 1 row affected (0.00 sec)

    事务A

    mysql> select * from test;
    +----+----+
    | a | b |
    +----+----+
    | 14 | 14 |
    | 16 | 16 |
    | 10 | 20 |
    | 31 | 31 |
    | 33 | 33 |
    | 38 | 38 |
    | 50 | 60 |
    | 70 | 70 |
    +----+----+
    8 rows in set (0.00 sec)

    事务B

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

    事务A 此时若不commit,是看不到事务B insert的数据的

    mysql> select * from test;
    +----+----+
    | a | b |
    +----+----+
    | 14 | 14 |
    | 16 | 16 |
    | 10 | 20 |
    | 31 | 31 |
    | 33 | 33 |
    | 38 | 38 |
    | 50 | 60 |
    | 70 | 70 |
    +----+----+
    8 rows in set (0.00 sec)

    commit;

    mysql> select * from test;
    +----+----+
    | a | b |
    +----+----+
    | 14 | 14 |
    | 16 | 16 |
    | 10 | 20 |
    | 31 | 31 |
    | 33 | 33 |
    | 38 | 38 |
    | 50 | 60 |
    | 70 | 70 |
    | 80 | 80 |
    +----+----+
    9 rows in set (0.00 sec)

  • 相关阅读:
    List.Foreach与C#的foreach的区别
    他们突然觉得我懂的还挺多,嘎嘎~
    Mysql跨表更新 多表update sql语句总结
    “你没有权限登录JIRA”的解决办法
    iis日志查看
    自已写的Json序列化方法,可以序列话对象的只读属性
    mysql --limit
    python切片
    数据库
    tarzan-linux命令
  • 原文地址:https://www.cnblogs.com/taek/p/4748889.html
Copyright © 2011-2022 走看看