gpt4 book ai didi

mysql - 存储过程中的 DML 是否在单个事务中运行?

转载 作者:行者123 更新时间:2023-11-29 00:25:46 28 4
gpt4 key购买 nike

我的 MySQL 5.5 服务器已设置 autocommit=1

我的存储过程有几个 DML,但没有明确的事务管理。

当我从 MySQL CLI 发出 call the_procedure() 时(autocommit 仍为 1),所有过程的 DML 是否都在一个事务中运行?

或者它们是否在单独的事务中运行,并在每个 DML 之后导致隐式事务提交(由于自动提交)?

最佳答案

This令我惊讶的是:

Although MySQL will automatically initiate a transaction on yourbehalf when you issue DML statements, you should issue an explicitSTART TRANSACTION statement in your program to mark the beginning ofyour transaction.

It's possible that your stored program might be run within a server inwhich autocommit is set to TRUE, and by issuing an explicit STARTTRANSACTION statement you ensure that autocommit does not remainenabled during your transaction. START TRANSACTION also aidsreadability by clearly delineating the scope of your transactionalcode.

关于mysql - 存储过程中的 DML 是否在单个事务中运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18995300/

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