mysql 事务隔离级设置
如何查看当前SESSION的事务隔离级
mysql 默认的事务隔离级是 REPEATABLE-READ
可以通过以下命令查看当前session的事务隔离级(5.7.20之前)
1 2 3 4 5 6 7
| MariaDB [(none)]> select @@session.tx_isolation; +------------------------+ | @@session.tx_isolation | +------------------------+ | REPEATABLE-READ | +------------------------+ 1 row in set (0.00 sec)
|
如何修改事务隔离级
1 2 3 4 5 6 7 8 9 10 11 12 13
| SET [GLOBAL | SESSION] TRANSACTION transaction_characteristic [, transaction_characteristic] ...
transaction_characteristic: ISOLATION LEVEL level | READ WRITE | READ ONLY
level: REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED | SERIALIZABLE
|
- GLOBAL:代表对随后所有的SESSION都生效,已经建立的SESSION不受影响
- SESSION: 代表只对当前的SESSION生效