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;