READ-COMMITTED 不能进行可重复读和防止幻读

mysql> SELECT @@GLOBAL.tx_isolation, @@tx_isolation; 
+-----------------------+----------------+
| @@GLOBAL.tx_isolation | @@tx_isolation |
+-----------------------+----------------+
| REPEATABLE-READ       | READ-COMMITTED |
+-----------------------+----------------+
1 row in set (0.00 sec)

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

mysql>  select * from t100;
+-----+-------+
| id  | value |
+-----+-------+
|   1 | a     |
|   8 | a     |
| 100 | a     |
| 200 | a     |
| 300 | a     |
| 400 | a     |
| 500 | a     |
| 600 | a     |
| 700 | a     |
+-----+-------+                                    commit;


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


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

阅读更多
个人分类: Introduction to InnoDB
上一篇REPEATABLE-READ 预读
下一篇perl dbi 控制事务
想对作者说点什么? 我来说一句

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

关闭
关闭