All HowTo's Linux Administrators PostgreSQL

PostgreSQL DB-Level Snapshots with BEGIN and ROLLBACK

PostgreSQL allows for a kind of snapshot to be taken before changes are made. Once the changes have been made, the administrator has the option to accept the changes or roll back to the previous state. Test before use. Note that any changes made between the “BEGIN” and the “ROLLBACK” will be lost.

This article explains the process. The following commands are executed within PostgreSQL .

Take the snapshot:

BEGIN;

Accept the changes:

COMMIT;

Don’t accept the changes and rollback to the previous state:

ROLLBACK;

A good resource that explains the process well can be found here “https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-transaction/”.

Leave a Reply

Your email address will not be published. Required fields are marked *