I. Isolation levels and phenomena
There are 4 levels of database isolation
Read uncomitted, unauthorized reading
Read Committed, authorized to read
REPEATABLE Read, repeatable reading
Serializable, serialization
There are 3 types of inconsistencies that may occur
Dirty Read
Non-REPEATABLE READ
Phantom reading
Two, 3 kinds of phenomena
Dirty read, is read dirty data, another transaction modified data but not submitted, we read this uncommitted data is dirty data, this phenomenon is dirty read;
Take a chestnut, balance. The field value is 100, the other transaction is modified to 200, the uncommitted time we read 200, and then the transaction is rolled back, the actual value should be 100, but we read 200;
Non-repeatable read, that is, for a data, I repeat the value of the time when it changed, that is, two reads were modified by another transaction;
Another chestnut, I read the Balance field value of 100, I made a judgment (such as whether it is greater than 0), and then I read it again when it becomes 200; for 100 this value I did not read repeatedly, that is, the occurrence of non-repeatable reading;
Phantom reading, is to read again found a new record or less records, thinking that there is an illusion;
The last chestnut, when I read the data without the Balance field, I want to add balance to 0 o'clock, prompting me to exist in this field; I read this record for the second time, and I thought the first time I read it, there was an illusion;
Most of the scenes I read the first time after reading (perhaps modified a piece of data after reading), locked the one I read the data, but another transaction changed the table of other data, I read the second time I thought the first read a hallucination (it may be the first time to modify the whole table, another transaction changed only one data, I thought I hadn't succeeded in modifying the data);
Third, isolation level
|
Dirty Read |
Non-REPEATABLE READ |
Phantom reading |
Read UNCOMMITTED |
May occur |
May occur |
May occur |
Read committed |
|
May occur |
May occur |
REPEATABLE READ |
|
|
May occur |
REPEATABLE READ |
|
|
|
Database isolation dirty Read and non-repeatable read