3

我正在尝试在 Oracle 11g 中创建一个保存点。

ALTER TABLE ORDERS
DISABLE CONSTRAINT ORDERS_C_ID_FK;

DELETE FROM CUSTOMER;

SELECT * FROM CUSTOMER;

ROLLBACK;

SELECT * FROM CUSTOMER;

SAVEPOINT SAVEPOINT1;

ALTER TABLE ORDERS
DISABLE CONSTRAINT ORDERS_OS_ID_FK;

ALTER TABLE ORDER_LINE
DISABLE CONSTRAINT ORDER_LINE_O_ID_FK;

TRUNCATE TABLE CUSTOMER;
TRUNCATE TABLE ORDER_SOURCE;
TRUNCATE TABLE ORDERS;
DELETE FROM ORDERS;

ROLLBACK TO SAVEPOINT1;

但我不断从 SQL Developer 收到此错误

ROLLBACK TO SAVEPOINT1 错误报告:SQL 错误:ORA-01086:保存点 'SAVEPOINT1' 从未在此会话中建立或无效 01086. 00000 - “保存点 '%s' 从未建立” *原因:试图回滚到一个保存点从未成立。*行动:

4

1 回答 1

6

DDL语句ALTER TABLE——TRUNCATE TABLE在这种情况下——在它们执行之前和之后发出隐式提交。创建保存点的事务在ALTER TABLE执行第一条语句之前结束。DDL由于只能回滚到当前事务中定义的保存点,因此发出语句后不能回滚到保存点。

于 2012-11-21T03:24:17.917 回答