DDL语句是否总是为您提供隐式提交,还是可以得到隐式回滚? [英] Do DDL statements always give you an implicit commit, or can you get an implicit rollback?

查看:116
本文介绍了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之前进行回滚和在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语句是否总是为您提供隐式提交,还是可以得到隐式回滚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆