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 

  • 相关阅读:
    树莓派 官方800万摄像头 参数
    51单片机 小车 L298N pwm调速 串口控制 按键控制
    51单片机 HC05蓝牙模块
    python 类属性和实例属性、方法 访问权限问题
    python 通过setup.py安装和卸载python软件包
    win10家庭版安装
    python 测试用例
    python 异常类型
    抽象工厂模式
    (转)UML类图与类的关系详解
  • 原文地址:https://www.cnblogs.com/chengpeng15/p/9324476.html
Copyright © 2011-2022 走看看