oracle-databaserollback

ROLLBACK in ORACLE fails


SELECT * FROM BOOKS;  -- 100 ROWS returned.  
DELETE FROM BOOKS;  -- 100 rows deleted  
SELECT * FROM BOOKS;  -- no rows returned.  
ROLLBACK; --Rollback complete.  
SELECT * FROM BOOKS;  -- no rows returned.

I expected that ROLLBACK would bring all the rows back and the last select statement will return 100 rows. But it returns no rows.

I am leaning SQL using ORACLE database. The rollback fails.


Solution

  • It's most probably because you didn't commit the first insert of the 100 rows: then when doing the rollback you are back to the situation before the insert. Do: INSERT COMMIT DELETE ROLLBACK and you will see back you 100 inserted rows.