1. Read UnCommitted
Session1 | Session2 |
set autocommit = 0; set session transaction isolation level read uncommitted; | |
set autocommit = 0; set session transaction isolation level read uncommitted; | |
| |
uncommited. | |
|
Conclusion : Dirty Read
2. Read Committed
Session1 | Session2 |
set autocommit = 0; set session transaction isolation level read committed; | |
set autocommit = 0; set session transaction isolation level read committed; | |
| uncommited. |
| |
| |
| |
| |
产生了不可重复读问题 | |
| |
产生了幻读 |
Conclusion : Can Not Dirty Read, Can Not Repeatable Read
3. Repeatable Read
Session1 | Session2 |
set autocommit = 0; set session transaction isolation level repeatable read; | |
set autocommit = 0; set session transaction isolation level repeatable read; | |
| |
| |
可重复读 | |
| |
没有幻读 |
Conclusion : 可以重复读,没有幻读,注意幻读不是这个隔离级别一定会控制的,跟各个数据库对隔离级别的实现有关。
4. Serializable
Session1 | Session2 |
set autocommit = 0; set session transaction isolation level Serializable; | |
set autocommit = 0; set session transaction isolation level Serializable; | |
| |
|
Conclusion : 串行执行