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)