更新时间:2024-07-24 GMT+08:00

START TRANSACTION

语法

START TRANSACTION [ mode [, ...] ]

其中mode用于设置事务的隔离级别,可选的参数有:

ISOLATION LEVEL { READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE }

READ { ONLY | WRITE }

描述

在当前会话下,开启一个新的事务。

示例

START TRANSACTION;
START TRANSACTION ISOLATION LEVEL REPEATABLE READ;
START TRANSACTION READ WRITE;
START TRANSACTION ISOLATION LEVEL READ COMMITTED, READ ONLY;
START TRANSACTION READ WRITE, ISOLATION LEVEL SERIALIZABLE;

不支持嵌套事务,也就是开启事务后,在commit之前不能再开启其他事务。