Concurrency and Data Reading
When multiple sessions simultaneously access (operate) the same data, unexpected results may occur, including:
-Dirty read -- dirty reads
-Non-repeatable reads
-Phantom read-Phantom reads
1. Dirty read refers to when a transaction is accessing data and modifying the data, but the modification has not been committed to the database, another transaction also accesses the data and then uses the data. Because the data has not been committed, the data read by another transaction is dirty data. The figure below may be better understood: 2. Non-repeated reads and non-repeated reads indicate that two identical queries within a transaction range return different data during database access, this is because the data has been modified and committed by other transactions in the system during the query. For example, when transaction T1 reads a data, transaction T2 reads and modifies the data, and T1 reads the data again, it is found that it is different from the first read.
As shown in the following figure: 3. When Phantom reads the same SQL statement twice in the same transaction, the result set is different.
Transaction isolation level (ANSI defined level)
The four transaction isolation levels defined by ANSI in the standard organization: