REPEATABLE-READ 预读

<pre name="code" class="sql">SELECT @@GLOBAL.tx_isolation, @@tx_isolation; 

SESSION A:                                                SESSION B:
set autocommit=0;                                          set autocommit=0;
start transaction;    
mysql> select * from t100;
+-----+-------+
| id  | value |
+-----+-------+
|   1 | a     |
| 100 | a     |
| 200 | a     |
| 300 | a     |
| 400 | a     |
| 500 | a     |
| 600 | a     |
+-----+-------+                                          
                                                       insert into t100 values(700,'a');

mysql> select * from t100;
+-----+-------+
| id  | value |
+-----+-------+
|   1 | a     |
| 100 | a     |
| 200 | a     |
| 300 | a     |
| 400 | a     |
| 500 | a     |
| 600 | a     |
+-----+-------+
7 rows in set (0.00 sec) 
                                                             commit;


mysql>  select * from t100;
+-----+-------+
| id  | value |
+-----+-------+
|   1 | a     |
| 100 | a     |
| 200 | a     |
| 300 | a     |
| 400 | a     |
| 500 | a     |
| 600 | a     |
+-----+-------+
7 rows in set (0.00 sec)

此时SESSION A看不到SESSION B的插入:




            
阅读更多
个人分类: Introduction to InnoDB
上一篇【MySQL】gap lock 浅析
下一篇READ-COMMITTED 不能进行可重复读和防止幻读
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭