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
, and SERIALIZABLE
。
默认为 REPEATABLE READ
可用通过一下命令更高隔离模式:
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
全局更改数据库模式,使用如下命令
或者更高数据库默认启动参数:
[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 for InnoDB
. Consistent reads within the same transaction read the snapshot established by the first read. This means that if you issue several plain (nonlocking) SELECT
statements within the same transaction, these SELECT
statements are consistent also with respect to each other. See Section 14.7.2.3, “Consistent Nonlocking Reads”.
For locking reads (SELECT
with FOR UPDATE
or LOCK IN SHARE MODE
), UPDATE
, and DELETE
statements, 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,
InnoDB
locks only the index record found, not the gap before it. -
For other search conditions,
InnoDB
locks the index range scanned, using gap locks or next-key locks to block insertions by other sessions into the gaps covered by the range. For information about gap locks and next-key locks,
【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)