mysql 事物隔离级别

【摘要】 InnoDB 提供四种隔离级别 READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, and SERIALIZABLE。默认为 REPEATABLE READ可用通过一下命令更高隔离模式:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;全局更改数据库模式,使用如下命令 –transaction-iso…

InnoDB提供四种隔离级别READ UNCOMMITTED,READ COMMITTED,REPEATABLE READ, andSERIALIZABLE

默认为REPEATABLE READ

可用通过一下命令更高隔离模式:

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

全局更改数据库模式,使用如下命令

--transaction-isolation=level

或者更高数据库默认启动参数:

[mysqld]

transaction-isolation = REPEATABLE-READ

transaction-read-only = OFF

查询当前数据库状态:

SELECT @@GLOBAL.transaction_isolation, @@GLOBAL.transaction_read_only;

SELECT @@SESSION.transaction_isolation, @@SESSION.transaction_read_only;

默认:

REPEATABLE READ

This is the default isolation level forInnoDB.Consistent readswithin the same transaction read thesnapshotestablished by the first read. This means that if you issue several plain (nonlocking)SELECTstatements within the same transaction, theseSELECTstatements are consistent also with respect to each other. SeeSection14.7.2.3, “Consistent Nonlocking Reads”.

Forlocking reads(SELECTwithFOR UPDATEorLOCK IN SHARE MODE),UPDATE, andDELETEstatements, locking depends on whether the statement uses a unique index with a unique search condition or a range-type search condition.

  • For a unique index with a unique search condition,InnoDBlocks only the index record found, not thegapbefore it.

  • For other search conditions,InnoDBlocks the index range scanned, usinggap locksornext-key locksto block insertions by other sessions into the gaps covered by the range. For information about gap locks and next-key locks,

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享