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 

  • 相关阅读:
    cfdem链接库地址不对的解决方法(liblmp_auto.so)
    总结入门学习OpenFOAM的资料(网址、论坛、帖子、博客等)
    运行cfdemCFDEMuti编译时出现的错误
    mapreduce 的三种测试方式
    Shell 编程
    hadoop集群搭建
    hadoop的环境配置
    hadoop 模板虚拟机环境准备以及对模板机的克隆
    linux总结
    解决maven控制台出现乱码情况
  • 原文地址:https://www.cnblogs.com/chengpeng15/p/9324476.html
Copyright © 2011-2022 走看看