Introduction to MySQL transactions and InnoDB lock types
This article gives you an introduction to MySQL transactions and InnoDB lock types. The article covers the knowledge of MySQL transactions and InnoDB lock types. I hope you can get something from this article.
I. isolation level of the transaction
1. 4 isolation levels
(1) uncommitted read (Read uncommitted): one transaction reads uncommitted data from other transactions, which is the lowest isolation mechanism.
(2) commit Read committed: one transaction reads the data committed by another transaction.
(3) Repeatable read: a transaction reads the same data in the same way, regardless of other transactions' modifications to the data.
(4) Serializable: transaction serialization is executed with the highest isolation level at the expense of system concurrency.
2. Problems solved by different isolation levels
If the isolation level of the transaction is not considered, the concurrency of the transaction can cause the following problems:
(1) dirty reading: transaction A reads the data updated by transaction B, and then B rolls back the operation, then the data read by An is dirty data.
(2) non-repeatable reading: transaction A reads the same data many times, and transaction B updates and commits the data in the process of reading the same data many times, resulting in inconsistent results when transaction A reads the same data many times.
(3) Phantom reading: reading the same range of data in the same transaction, but resulting in more data or less data, this is called phantom reading. (just like a transaction to id