gpt4 book ai didi

mysql - MySQL中是否允许嵌套事务?

转载 作者:IT老高 更新时间:2023-10-28 12:52:14 27 4
gpt4 key购买 nike

MySQL 是否允许使用嵌套事务?

最佳答案

不,但是

InnoDB 支持 SAVEPOINTS

您可以执行以下操作:

CREATE TABLE t_test (id INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;

START TRANSACTION;

INSERT
INTO t_test
VALUES (1);

SELECT *
FROM t_test;

id
---
1

SAVEPOINT tran2;

INSERT
INTO t_test
VALUES (2);

SELECT *
FROM t_test;

id
---
1
2

ROLLBACK TO tran2;

SELECT *
FROM t_test;

id
---
1

ROLLBACK;

SELECT *
FROM t_test;

id
---

关于mysql - MySQL中是否允许嵌套事务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1306869/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com