Database Management Systems (2130703)

BE | Semester-3   Summer-2018 | 05/23/2018

Q3) (b)

Compare rollback with commit SQL commands.

COMMIT

  • The COMMIT command is the transactional command used to save changes invoked by a transaction to the database.
  • The COMMIT command saves all transactions to the database since the last COMMIT or ROLLBACK command.

Example:

Student
Rollno Name SPI
1 Raju 8
2 Hari 9
3 Mahesh 7
 
SQL> DELETE FROM STUDENT WHERE SPI < 9 ;
SQL> COMMIT;
 

OUTPUT:

Student
Rollno Name SPI
1 Raju 8
2 Hari 9
 

ROLLBACK

  • The ROLLBACK command is the transactional control command used to undo transactions that have not already been saved to the database.
  • The ROLLBACK command can only be used to undo transactions since the last COMMIT or ROLLBACK command was issued.
 

Example:

Student
Rollno Name SPI
1 Raju 8
2 Hari 9
3 Mahesh 7
 
SQL> DELETE FROM STUDENT WHERE SPI < 8;
SQL> COMMIT;
 

OUTPUT

Student
Rollno Name SPI
1 Raju 8
2 Hari 9
3 Mahesh 7