PostgreSQL: COMMIT, ROLLBACK and SAVEPOINT for Transactions

Today morning, one of our Associate DB Developer working with Transactions and PostgreSQL is also new for him.
The COMMIT, ROLLBACK and SAVEPOINT are very common for all RDBMS.

In this post, I am sharing one basic demonstration on COMMIT, ROLLBACK and SAVEPOINT of PostgreSQL which helps to Associate level DB Developer.

Create a table with Sample Data:

Commit: We can use COMMIT to end our all transactions and make It as permanent changes.

Commit the Transaction:

Rollback: Using ROLLBACK, we can jump to the previous last committed state of the Transaction.
Rollback the Transaction:

Savepoint: Using SAVEPOINT, we can jump to the particular point which defines by the SAVEPOINT.

Rollback changes to the Save Point:

The Result:

Anvesh Patel

Leave a Reply

Be the First to Comment!

Notify of