The SQL92 standard stipulates that database transactions have 4 isolation levels in order to prevent the following behavior:
- Dirty Read (Dirty Read): One transaction has read UNCOMMITTED data from another transaction
- A transaction modifies a piece of data but is still not committed
- b Transaction query data, but can read the PEN uncommitted data (if a transaction rollback, this pen data is dirty data, so dirty Read)
- Non-repeatable read (nonrepeatable Read):
- A transaction reads a batch of data
- b Transaction operation or delete the batch data
- A transaction is read again, it is found that the batch data has been modified or deleted
- Non-existent read (Phantom Read):
- A transaction queries a batch of data based on conditions
- B Transaction Insert Data
- A transaction re-executes the same condition of the query, the result set is inconsistent
The isolation level for database transactions is:
Isolation level |
Dirty Read |
Non-REPEATABLE READ |
does not exist read |
Non-committed read |
Y |
Y |
Y |
Read Committed |
N |
Y |
Y |
REPEATABLE READ |
N |
N |
Y |
Serialization |
N |
N |
N |
I think that, based on the atomicity of database transactions, consistency, dirty reading is a heavy priority, this point is very easy to understand.
Non-repeatable read, no read, at first glance as if consistent. In fact, it is not repeatable to read, the database only need to ensure the isolation of the data being manipulated, but there is no read, the database needs to ensure the data isolation of the entire table. So they have different levels.
Isolation level for database transactions