Quick Search:
 
 The Oracle PL/SQL ROLLBACK Statement      [Return To Index] Jump to:  

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 |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org