2012-11-21 63 views
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開發人員收到此錯誤

ROLLBACK TO SAVEPOINT1 Error report: SQL Error: ORA-01086: savepoint 'SAVEPOINT1' never established in this session or is invalid 01086. 00000 - "savepoint '%s' never established" *Cause: Trying to roll back to a save point that was never established. *Action:

回答

6

DDL statements--在這個ALTER TABLETRUNCATE TABLE它們被執行之前和之後case--發出含蓄的提交。保存點創建的事務在執行第一條ALTER TABLE語句之前已結束。由於您只能回滾到當前事務中定義的保存點,因此在發出DDL語句後無法回滾到保存點。

相關問題