Let us go through the details related to Transactions. We typically perform operations such as COMMIT and ROLLBACK via the applications.
- COMMIT will persist the changes in the database.
- ROLLBACK will revert the uncommitted changes in the database.
- We typically rollback the uncommitted changes in a transaction if there is any exception as part of the application logic flow.
- For example, once the order is placed all the items that are added to the shopping cart will be rolled back if the payment using a credit card fails.
- By default, every operation is typically committed in Postgres. We will get into the details related to transactions as part of application development later.
- Commands such as COMMIT, ROLLBACK typically come under TCL (Transaction Control Language)