Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle PL/SQL ROLLBACK Statement      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: ROLLBACK

Definition:
In Oracle PL/SQL, ROLLBACK is a TCL (Transaction Control Language) command, which is used as "undo" feature in SQL. If a transaction or set of transactions has been done on a set of table data, it can be reverted in the same session using the ROLLBACK command.

Example Syntax:

SQL> ROLLBACK;


Example Usage:

The SELECT below statement shows the current data in the TEST table:

SQL> SELECT * FROM TEST;

ID NAME LNAME
---------- -------------------- ----------
1 CLUB ORACLE
2 SCOTT HR


The INSERT statement below inserts a new record into the TEST table, and the SELECT statement confirms the insertion of the new record:

SQL> INSERT INTO TEST VALUES (3,'PSOUG','ORACLE');

1 row created.

SQL> SELECT * FROM TEST;

ID NAME LNAME
---------- -------------------- ----------
1 CLUB ORACLE
2 SCOTT HR
3 PSOUG ORACLE


The ROLLBACK command is now executed to revert back the last set of transactions done on the table:

SQL> ROLLBACK;

Rollback complete.

SQL> SELECT * FROM TEST;

ID NAME LNAME
---------- -------------------- ----------
1 CLUB ORACLE
2 SCOTT HR



Related Links:

Related Code Snippets:
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 103 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?