Brief summary of the isolation level of database transactions, Database Transaction Level
There are four transaction isolation levels in the database: Read uncommitted, Read committed, Repeatable read, and Serializable. These four levels can solve dirty reads, non-repeated reads, and Phantom reads one by one.
If the current isolation level is Read uncommitted, dirty reads may occur, that is, temporary write data that has not been submitted may be Read.
If the current isolation level is Read committed, it can avoid dirty reads, but may cause non-repeated reads. That is, when two transactions modify the same data at the same time, the data consistency and integrity are damaged. Most databases use Read committed by default, such as SQL Server and Oracle.
If the current isolation level is Repeatable read, you can avoid repeated reads, that is, when two or more transactions read the same data, the database selects the readable and writable transaction for the first data access, and the read-only transaction for the second and later transactions. Although this can avoid repeated reads, when transaction A reads the same data twice, if another transaction that can read or write the database modifies the data during the period, therefore, the results of two data reads by transaction A are likely to be inconsistent, that is, phantom read.
The highest level of transaction isolation in the database during Serializable serialization. At this level, transactions are executed in order to avoid dirty reads, repeated reads, and Phantom reads, however, the cost is high and the performance is low.