There are 4 isolation levels for database transactions, from low to High:
Read UNCOMMITTED |
READ UNCOMMITTED read not authorized |
Read to allow other Two transactions cannot be written at the same time |
Transaction B reads transaction A for the submitted data |
Avoid dirty reads when updates are lost |
Read committed |
Authorize read Read commit |
Read to allow other uncommitted transactions to prevent other transactional accesses from being made |
Transaction a reads data transaction b changes data transaction A reads B changed data, inconsistent results |
Prevent Dirty reads from appearing as non-repeatable reads (duplicate read results are different) |
REPEATABLE READ |
REPEATABLE READ |
Read does not allow write transactions to write prohibit other transactions from being made |
Transaction a reads R1 and modifies R2 transaction B cannot modify R1 and read r2,b does not affect a If a contains a statistic that records a range of operations, and B just inserts a record within the range, causing a phantom read |
REPEATABLE READ There will be Phantom reads |
Serializable |
Serialization of |
Transactions can only be executed one after another, not concurrently |
Highest transaction isolation level, low performance, typically rarely used |
Avoid dirty reading , avoid non-repetition reading , avoid phantom reading |
Four isolation levels for database transactions