| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle does not rollback correctly after ENABLE CONSTRAINT failed
John K. Hinsdale schrieb:
>> On 5 feb, 16:52, uhaham_at_gmail.com wrote: >>> After a failed attempt to enable foreign key the rollback did not >>> return to the original database state.
>> DDL always do an implicit COMMIT. It is done BEFORE the DDL. So, it >> doesn't matter if the DDL succeeds or fails: the commit is done (no >> chance for a rollback then).
You are surely aware, that, in opposite to Carlos example, yours will get a parse error ( you can easily see it in the 10046 trace) and so never will be executed, so no impact on previous transaction. A valid DDL statement (like alter table add constraint in previous example) will be executed , error occurs within recursive sql and statement itself fails, but transaction is commited exactly due to reason mentioned by Carlos.
Here a variation of your example
SQL> alter session set events '10046 trace name context forever,level 12';
Session altered.
SQL> create table foo ( n number );
Table created.
SQL> select * from foo;
no rows selected
SQL> insert into foo values ( 10 );
1 row created.
SQL> select * from foo;
N
10
SQL> create table bar ( );
create table bar ( )
*
SQL> select * from foo;
N
10
SQL> rollback;
Rollback complete.
SQL> insert into foo values(1);
1 row created.
SQL> alter table foo add constraint foo_c check (n>10); alter table foo add constraint foo_c check (n>10)
*
SQL> rollback;
Rollback complete.
SQL> select * from foo;
N
1
SQL> alter session set events '10046 trace name context off';
Best regards
Maxim Received on Mon Feb 05 2007 - 14:56:44 CST
![]() |
![]() |