BEGIN COMMIT; YOURE-DDL-OPERATOR; COMMIT; EXCEPTION WHEN OTHERS THEN ROLLBACK; RAISE; END;
This very simple example can demonstrate you that both commit statements are performed:
SQL> SELECT * FROM D1; no rows selected SQL> INSERT INTO D1 VALUES (1); 1 row created. SQL> ALTER TABLE D1 ADD A NUMBER; ALTER TABLE D1 ADD A NUMBER * ERROR at line 1: ORA-01430: column being added already exists in table SQL> ROLLBACK; Rollback complete. SQL> SELECT * FROM D1; A ---------- 1 SQL> INSERT INTO D1 VALUES (2); 1 row created. SQL> ALTER TABLE D1 ADD B NUMBER; Table altered. SQL> ROLLBACK; Rollback complete. SQL> SELECT * FROM D1; A B ---------- ---------- 1 2 SQL>Rows added and transaction commited whenever DDL operator completed successfully or not.
Also autocommit runs in some tools, did you know that sqlplus do it every time you exit?
SQL> select * from d1; no rows selected SQL> insert into d1 values (1); 1 row created. SQL> select * from d1; A ---------- 1 SQL> exit Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 - Produ ction D:\Documents and Settings\501752478>sqlplus hr/hr@xe SQL*Plus: Release 10.2.0.1.0 - Production on TЄ L¦э 7 13:57:39 2011 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production SQL> select * from d1; A ---------- 1
No comments:
Post a Comment