SQL tutorial | Interview questions | Oracle
Would you like to react to this message? Create an account in a few clicks or log in to continue.

How To Rollback the Current Transaction?

Go down

How To Rollback the Current Transaction? Empty How To Rollback the Current Transaction?

Post by Micheal Sun Jan 17, 2010 3:27 am

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) VALUES ('google.com', 102);
SQL> INSERT INTO fyi_links (url, id) 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.

Micheal
Admin

Posts : 243
Join date : 2010-01-10

http://sql-tutorial.co.cc

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum