zoukankan      html  css  js  c++  java
  • 可重复读中的幻读

                               

     为什么更新完就可以查到了,隔离界别是可重复读。

    因为要更新,更新完后自然能查到。

    下面是只有更新的例子,也是可重复读。

    mysql> begin;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> select * from student;
    ERROR 1146 (42S02): Table 'dfcf.student' doesn't exist
    mysql> select * from students;
    +--------+------+-------+
    | name   | sex  | grade |
    +--------+------+-------+
    | 张1    | 女   |    87 |
    | 张11   | 女   |    87 |
    | 张111  | 女   |    87 |
    | 张三   | 女   |    87 |
    | 李2    | 女   |    87 |
    | 李22   | 女   |    87 |
    | 李222  | 女   |    87 |
    | 李四   | 女   |    87 |
    | 王3    | 女   |    87 |
    | 王33   | 女   |    87 |
    | 王333  | 女   |    87 |
    | 王五   | 女   |    87 |
    +--------+------+-------+
    12 rows in set (0.00 sec)
    
    
    mysql> update students set name = "xxx" where name="张1";
    Query OK, 1 row affected (0.03 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    mysql> select * from students;
    +--------+------+-------+
    | name   | sex  | grade |
    +--------+------+-------+
    | xxx    | 女   |    87 |
    | 张11   | 女   |    87 |
    | 张111  | 女   |    87 |
    | 张三   | 女   |    87 |
    | 李2    | 女   |    87 |
    | 李22   | 女   |    87 |
    | 李222  | 女   |    87 |
    | 李四   | 女   |    87 |
    | 王3    | 女   |    87 |
    | 王33   | 女   |    87 |
    | 王333  | 女   |    87 |
    | 王五   | 女   |    87 |
    +--------+------+-------+
    12 rows in set (0.00 sec)
    
    mysql> commit;
    Query OK, 0 rows affected (0.01 sec)
    

      

    mysql> begin;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> select * from students;
    +--------+------+-------+
    | name   | sex  | grade |
    +--------+------+-------+
    | 张1    ||    87 |
    | 张11   ||    87 |
    | 张111  ||    87 |
    | 张三   ||    87 |
    | 李2    ||    87 |
    | 李22   ||    87 |
    | 李222  ||    87 |
    | 李四   ||    87 |
    | 王3    ||    87 |
    | 王33   ||    87 |
    | 王333  ||    87 |
    | 王五   ||    87 |
    +--------+------+-------+
    12 rows in set (0.01 sec)
    
    mysql> select * from students;
    +--------+------+-------+
    | name   | sex  | grade |
    +--------+------+-------+
    | 张1    ||    87 |
    | 张11   ||    87 |
    | 张111  ||    87 |
    | 张三   ||    87 |
    | 李2    ||    87 |
    | 李22   ||    87 |
    | 李222  ||    87 |
    | 李四   ||    87 |
    | 王3    ||    87 |
    | 王33   ||    87 |
    | 王333  ||    87 |
    | 王五   ||    87 |
    +--------+------+-------+
    12 rows in set (0.00 sec)
    
    mysql> commit;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> select * from students;
    +--------+------+-------+
    | name   | sex  | grade |
    +--------+------+-------+
    | xxx    ||    87 |
    | 张11   ||    87 |
    | 张111  ||    87 |
    | 张三   ||    87 |
    | 李2    ||    87 |
    | 李22   ||    87 |
    | 李222  ||    87 |
    | 李四   ||    87 |
    | 王3    ||    87 |
    | 王33   ||    87 |
    | 王333  ||    87 |
    | 王五   ||    87 |
    +--------+------+-------+
    12 rows in set (0.00 sec)

    轻松理解MYSQL MVCC 实现机制参考这个文章

    https://www.cnblogs.com/chengpeng15/p/9326840.html 

  • 相关阅读:
    osgi实战学习之路:8. Service-3之ServiceTracker
    使用Jquery+EasyUI 进行框架项目开发案例解说之二---用户管理源代码分享
    QQ音乐产品经理黄楚雄:产品与用户的情感联系
    AsyncTask简单入门
    晨跑感悟:三快三爽三熬
    【cocos2d-x制作别踩白块儿】第九期:游戏计时功能(附源代码)
    cocos2d3.0 Scale9Sprite
    新的历程-近两个月的工作总结
    基因突变的实例:加拿大无毛猫
    ANTS Performance Profiler 破解使用
  • 原文地址:https://www.cnblogs.com/chengpeng15/p/9324476.html
Copyright © 2011-2022 走看看