Home >> FAQs/Tutorials >> Oracle Tutorials

Oracle Tutorials - Rollback the Current Transaction

By: FYIcenter.com

(Continued from previous topic...)

How To Rollback the Current Transaction?

If you have used some DML statements updated some data objects, you find a problem with those updates, and you don't want those updates to be permanently recorded in the database, you can use the ROLLBACK statement. It will remove all the database changes made in the current transaction and end the current transaction. The following tutorial exercise shows you how to use ROLLBACK statements:

SQL> connect HR/fyicenter

SQL> INSERT INTO fyi_links (url, id) 
  2  VALUES ('google.com', 102);

SQL> INSERT INTO fyi_links (url, id) 
  3  VALUES ('myspace.com', 103);

SQL> SELECT * FROM fyi_links;
     ID URL              NOTES          COUNTS CREATED
------- ---------------- ---------- ---------- ---------
    101 fyicenter.com                          07-MAY-06
    110 centerfyi.com                          07-MAY-06
    102 google.com                             07-MAY-06
    103 myspace.com                            07-MAY-06

SQL> ROLLBACK;
Rollback complete.

SQL> SELECT * FROM fyi_links;
     ID URL              NOTES          COUNTS CREATED
------- ---------------- ---------- ---------- ---------
    101 fyicenter.com                          07-MAY-06
    110 centerfyi.com                          07-MAY-06

As you can see, the two new records inserted into the table were removed by the ROLLBACK statement.

(Continued on next topic...)

  1. What Is a Transaction?
  2. How To Start a New Transaction?
  3. How To End the Current Transaction?
  4. How To Create a Test Table for Transaction Testing?
  5. How To Commit the Current Transaction?
  6. How To Rollback the Current Transaction?
  7. What Happens to the Current Transaction If a DDL Statement Is Executed?
  8. What Happens to the Current Transaction If the Session Is Ended?
  9. What Happens to the Current Transaction If the Session Is Killed?
  10. How Does Oracle Handle Read Consistency?
  11. What Is a READ WRITE Transaction?
  12. What Is a READ ONLY Transaction?
  13. How To Set a Transaction To Be READ ONLY?
  14. What Are the Restrictions in a READ ONLY Transaction?
  15. What Are the General Rules on Data Consistency?
  16. What Are Transaction Isolation Levels Supported by Oracle?
  17. What Is a Data Lock?
  18. How Data Locks Are Respected?
  19. How To Experiment a Data Lock?
  20. How To View Existing Locks on the Database?
  21. What Is a Dead Lock?
  22. How Oracle Handles Dead Locks?

Oracle Tutorials:

More...


Other Tutorials/FAQs:

More...


Related Resources:

More...


Selected Jobs:

More...