Difference Between COMMIT and ROLLBACK in SQL


In this post, we will understand the difference between COMMIT and ROLLBACK in SQL.

COMMIT

  • It validates the modifications that are made by the current transaction.

  • Once the COMMIT statement has been executed, the transaction can’t be rolled back using ROLLBACK.

  • It occurs when the transaction is successfully executed.

Syntax

COMMIT;

ROLLBACK

  • It removes the modifications that were made by the current transaction.

  • Once ROLLBACK is executed, the database would reach its previous state.

  • This is the state where the first statement of the transaction would be in execution.

  • ROLLBACK happens when the transaction is aborted in between its execution.

Syntax

ROLLBACK;

Updated on: 25-Mar-2021

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements