Transactions and Isolation Levels
The concept of transaction: A transaction treats a series of operations on the database as a whole, or all of them succeed , or all fail. Using transactions, we can ensure the integrity of the database and the transactions are atomic.
Isolation level: The isolation level defines the isolation distance between transactions.
Dirty read: A dirty read occurs when a transaction reads uncommitted modifications of another transaction.
(Related video tutorial recommendation: mysql video tutorial)
Nonrepeated read (nonrepeated read): The same query is performed multiple times in the same transaction, due to other transaction submissions The modifications made result in different results returned each time, and non-repeatable reading occurs at this time.
Phantom read: The same query is performed multiple times in the same transaction. Due to the addition or deletion operations made by other transactions or submissions, a different result set is obtained each time. This occurs. Phantom reading.
Non-repeatable reading focuses on modification, while phantom reading focuses on adding or deleting. To solve non-repeatable reads, you only need to lock rows that meet the conditions, and to solve phantom reads, you need to lock the table.
MySQL has four transaction isolation levels
Read uncommitted(Read uncommitted)
Read committed(Read committed)
Repeated read(Repeated read)
Serializable
MySQL default isolation level is: Repeated read(Repeated read)
Related article tutorials Recommended: mysql tutorial
The above is the detailed content of mysql isolation level. For more information, please follow other related articles on the PHP Chinese website!