Oracle:DDL 和事务回滚
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4711447/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle: DDL and transaction rollback
提问by FoxyBOA
Could in Oracle DDL (create/alter) be transactional like they are in MS SQL (started from 2005)?
在 Oracle DDL(创建/更改)中是否可以像在 MS SQL(从 2005 年开始)中那样进行事务处理?
采纳答案by GolezTrol
No. In Oracle DDL statements themselves are not transactional.
不可以。在 Oracle DDL 语句本身不是事务性的。
Running a DDL statement will implicitly commit any open transaction for that session before starting the actual work.
在开始实际工作之前,运行 DDL 语句将隐式提交该会话的任何打开事务。
In addition some statements, like an alter table statement, may fail if another session has an open transaction on the object being modified or one of its dependencies. You can set a ddl_lock_timeoutto specify how long you want Oracle to wait for the object to become available.
此外,如果另一个会话在正在修改的对象或其依赖项之一上具有打开的事务,则某些语句(如更改表语句)可能会失败。您可以设置ddl_lock_timeout来指定您希望 Oracle 等待对象变为可用的时间。
See DDL Statementsfor a summary of types of DDL statements and information about their behaviour regarding locks and transactions.
回答by Vincent Malgrat
回答by ddevienne
Just discovered this, so needs more investigation, but Oracle's create schema authorizationat least allows to bundle several DDL statements in a single transaction, thus avoiding several commits, and guarantees no side-effects, i.e. a rollback, if any one of the DDL statement fails.
刚刚发现这个,所以需要多查查,但是Oracle的create schema授权至少允许在一个事务中捆绑多个DDL语句,从而避免多次提交,并且保证没有副作用,即回滚,如果任何一个DDL语句失败。
It is unclear whether the rollback applies to the wrappedDDL statements only, as-if the create schema started a save-point, or the outer transaction with possibly some prior DML statement.
目前尚不清楚回滚是否仅适用于包装的DDL 语句,就像创建模式启动了一个保存点一样,或者可能包含一些先前的 DML 语句的外部事务。
You still cannot avoid the commit after the last wrapped DDL statement complete successfully though.
但是,在最后一个包装的 DDL 语句成功完成后,您仍然无法避免提交。