关闭

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

392人阅读 评论(0) 收藏 举报
分类:
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的插入:

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1172946次
    • 积分:38496
    • 等级:
    • 排名:第102名
    • 原创:2810篇
    • 转载:14篇
    • 译文:0篇
    • 评论:46条
    文章分类
    最新评论