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 

  • 相关阅读:
    mysql 开发基础系列7 流程函数与其它函数
    mysql 开发基础系列6 数值与日期函数
    html5 浏览器端数据库
    html5 响应式布局
    css 文本溢出显示省略号
    js 字符串的操作
    js 图片轮播(一)
    css 弹出层-透明层
    js选项卡
    js获取当前时间显示在页面上
  • 原文地址:https://www.cnblogs.com/chengpeng15/p/9324476.html
Copyright © 2011-2022 走看看