Home  >  Article  >  Database  >  Introduction to the four transaction isolation levels of mysql database

Introduction to the four transaction isolation levels of mysql database

不言
不言forward
2019-03-04 15:20:332346browse

This article brings you an introduction to the four transaction isolation levels of the MySQL database. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Familiar with the four transaction isolation levels of mysql database:

(Related recommendations: MySQL tutorial)

Query the transaction isolation level in mysql

SELECT @@tx_isolation;

Introduction to the four transaction isolation levels of mysql database

read uncommitted (RU) read uncommitted:

In one transaction, you can read uncommitted changes of other transactions

read committed ( RC) read committed:

In one transaction, you can read changes that have been committed by other transactions

repetable read, (RR) repeatable read:

a transaction , until the end of the transaction, you can repeatedly read the data seen at the beginning of the transaction without changing
The default isolation level of mysql is RR
The difference between RR and RC is that RR isolation is used in a transaction The data read from a table is the same at all levels

##insert into a(...)select * from a
Transaction A Transaction B
begin;
select * from a



Under the RR isolation level: Transaction A’s secondary select query The result is the same, you cannot see the data inserted in transaction B

Under the RC isolation level: the second select query of transaction A can see the data inserted in transaction B

serializable (serial read ):

Even if each read requires a table-level shared lock, and each write requires a table-level exclusive lock, reading and writing between the two sessions will block each other.

The above is the detailed content of Introduction to the four transaction isolation levels of mysql database. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete