Do DDL statements always give you an implicit commit, or can you get an implicit rollback?(DDL 语句是否总是给你一个隐式提交,或者你能得到一个隐式回滚?)
问题描述
如果您在事务进行到一半并执行 DDL 语句(例如截断表),则事务将提交.
If you're halfway through a transaction and perform a DDL statement, such as truncating a table, then the transaction commits.
我想知道这种情况是否总是如此,根据定义,还是隐藏在某处的设置可以回滚事务而不是提交.
I was wondering whether this was always the case and by definition, or is there a setting hidden somewhere that would rollback the transaction instead of committing.
谢谢.
编辑以澄清...
我不打算在截断后回滚.我只想确认已经执行的声明绝对总是将在 DDL 之前提交.只是想确保某处没有系统属性,有人可以设置来破坏我的代码.
I'm not looking to rollback after a truncate. I just want to confirm that statements already carried out are absolutely always going to be committed before a DDL. Just want to make sure there isn't a system property somewhere that someone could set to wreck my code.
我理解需要在 DDL 之前和之后提交,但从概念上讲,我认为可以通过在 DDL 之前回滚和之后提交来实现相同的一致性要求.
I understand the need to commit before and after a DDL, but conceptually I'd have thought the same consistency requirement could be achieved with a rollback before the DDL and a commit after.
推荐答案
不,它会一直提交.
如果要回滚,必须在 DDL 之前进行.
If you want to rollback, you'll have to do it before the DDL.
如果您想将 DDL 与现有事务隔离,那么您必须在它自己的独立事务中执行它.
If you want to isolate the DDL from your existing transaction, then you will have to execute it in its' own, separate transaction.
这篇关于DDL 语句是否总是给你一个隐式提交,或者你能得到一个隐式回滚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:DDL 语句是否总是给你一个隐式提交,或者你能得到一个隐式回滚?


基础教程推荐
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 带更新的 sqlite CTE 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01