SAVEPOINT

Now we will see how savepoint is used in COMMIT and ROLLBACK.

Savepoint:
  • Way of implementing subtranction .
Syntax:

Savepoint name;

Here Savepoint is a keyword used for creating the savepoint name is name of savepoint to be created.all changes made  after a savepoint has been declared can be undone by issuing  the ROLLBACK to a savepoint name .we can use it save the changes permanently by issuing the COMMIT to a savepoint name.

Example:

  Lets say we create a savepoint ‘s’ by issuing the following statement

Savepoint s;


 Now we are going to update different coloumn by update statement

Update emp set salary=salary+100;

Update emp set emp_contactno=’9830755710’ where emp_name=’abhishek’;


Finally we can leave the above changes by issuing the

Rollback to savepoint s ;

This will discard all the above changes made to database upto the savepoint s.
If we want to store the chages permanently to the database then we can use the commit command instead of rollback like this

Commit to savepoint s;

This will save all the above changes made to database upto the savepoint s.

Related Article:
   I am interested in hearing your feedback, so that I can improve my articles and learning resources for you.connect with us on facebooktwitter

Share

Did you enjoy reading this and found it useful? If so, please share it with your friends:

ROLLBACK

 In this lesson we are going to study about how to discard all changes made in database.


Rollback:
  • It is used to discard the changes made on database .
  • This command discards all the changes made on the database since the last transaction .
Syntax:

ROLLBACK;

  After excuting  the ROLLBACK statement the state of data is rolled back to the way it was the changes where made .

Example:
  Lets say we are going to update the salary of all employees  with 100.

Update emp set salary=salary+100;


  This statement update the salary of  emp table  with 100 mean while the chages  made on this table not written to the database until the session is closed or the user COMMIT the transaction .
 ROLLBACK  is used in a situation when we want to leave the above changes .So we can ROLLBACK  to above changes made on the database using the ROLLBACK command.

ROLLBACK;


Related Article:

 I am interested in hearing your feedback, so that I can improve my articles and learning resources for you.connect with us on facebooktwitter

Share

Did you enjoy reading this and found it useful? If so, please share it with your friends: