I have a program that periodically updates its database schema. Sometimes one of the DDL statements can fail, and if that happens, I want to undo all the changes. I transfer the update to the transaction as follows:
BEGIN TRAN; CREATE TABLE A (PKey int NOT NULL IDENTITY, NewFieldKey int NULL, CONSTRAINT PK_A PRIMARY KEY (PKey)); CREATE INDEX A_2 ON A (NewFieldKey); CREATE TABLE B (PKey int NOT NULL IDENTITY, CONSTRAINT PK_B PRIMARY KEY (PKey)); ALTER TABLE A ADD CONSTRAINT FK_B_A FOREIGN KEY (NewFieldKey) REFERENCES B (PKey); COMMIT TRAN;
As we execute, if one of the statements fails, I do ROLLBACK instead of COMMIT. This works fine on SQL Server, but does not have the desired effect for Oracle. It seems that Oracle does an implicit COMMIT after each DDL statement:
Is it possible to disable this implicit commit?
source share