【MySQL】设置隔离级别(Isolation Levels)

Posted by 西维蜀黍 on 2023-07-20, Last Modified on 2023-07-26

Show Transaction Isolation Level

check session transaction level (mysql8+)

SELECT @@transaction_ISOLATION;

check global transaction level (mysql8+)

SELECT @@global.transaction_ISOLATION;

Set Transaction Isolation Level

# set global
SET GLOBAL transaction ISOLATION LEVEL READ UNCOMMITTED;
SET GLOBAL transaction ISOLATION LEVEL READ COMMITTED;
SET GLOBAL transaction ISOLATION LEVEL REPEATABLE READ;
SET GLOBAL transaction ISOLATION LEVEL SERIALIZABLE;

# set session
SET session transaction ISOLATION LEVEL READ UNCOMMITTED;
SET session transaction ISOLATION LEVEL READ COMMITTED;
SET session transaction ISOLATION LEVEL REPEATABLE READ;
SET session transaction ISOLATION LEVEL SERIALIZABLE;

Reference