What is Rollback in Oracle?
- As you all are now familiar with the commit command or if not you can click here.
- Rollback in Oracle is used to reverse all of the changes done in the database before COMMIT is applied to it.
- In other words, Rollback is just an undo button used to undo all changes done before saving it.
Let's Consider we have a table, Stu, with values as shown below:
Now, as a user you need to make some operations in the table pasted above. But, you want those changes not to get saved. However, for that, you can use ROLLBACK Command.
Syntax
The syntax of the ROLLBACK command is written below:
Rollback;
Example
You made some changes in the Stu table by deleting some of its rows. However, after deleting some rows your output looks like below:
Now, if I need to unsave all the changes that I have applied, I will use the ROLLBACK command and get output as follows:
Output
Kindly find below the output of Stu Table after Rollback below: