USING ROLLBACK: - ROLLBACK is an opposite to COMMITT. It will undo the operation that we perform on database that is not yet committed.
Syntax: - ROLLBACK
We explicitly ROLLBACK the transaction if we wanted to revert any DML operation that occurred on the database.
Example for System ROLLBACK: While Work is under process, if suddenly power goes then oracle will ROLLBACK the transaction.
Ex: - First we are updating the record shown below
SQL> update EMP set sal=sal+1000 where ename='JOHN';
-- 1 updated
Now we will retrieve the record which we have updated by using SELECT Command shown below
SQL> select *from EMP where ename='JOHN';
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7125 SURESH ANALYST 7902 22-DEC-82 16000 1000 20
Now if we ROLLBACK then we can see below result
SQL> ROLLBACK;
Rollback complete.
Then again retrieving the record what we have updated by using SELECT command
SQL> select *from EMP where ename='JOHN';
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
--------- -------------------- --------- --------- --------- --------- --------- ---------
7125 SURESH ANALYST 7902 22-DEC-82 15000 1000 20
Here we can see it is Rollback (Sal from 16000 to 15000).
No comments:
Post a Comment