PostgreSQL is running in autocommit mode, so every statement is running in its own transaction unless you explicitly start a transaction with BEGIN or START TRANSACTION.

The only way you can get your data back is by restoring from a backup.

Answer from Laurenz Albe on Stack Overflow
🌐
Tutorialdba
tutorialdba.com › p › postgresql-rollback.html
PostgreSQL Rollback
April 22, 2017 - id | name | age | address | salary ----+-------+-----+-----------+-------- 1 | Paul | 32 | California| 20000 2 | Allen | 25 | Texas | 15000 3 | Teddy | 23 | Norway | 20000 4 | Mark | 25 | Rich-Mond | 65000 5 | David | 27 | Texas | 85000 6 | Kim | 22 | South-Hall| 45000 7 | James | 24 | Houston | 10000 --Now, let's start another transaction and delete records from the table having age = 25 and finally we use COMMIT command to commit all the changes. postgres=# BEGIN; DELETE FROM EMP WHERE AGE = 25; COMMIT; If you will check EMP table is still having the following records:
Discussions

backup - Postgresql revert back database value - Database Administrators Stack Exchange
I have postgresql database. My table name is tblvoippolicy. Now, problem is by mistake i have deleted some records from table. When I get the data file using following commands. select * from pg_c... More on dba.stackexchange.com
🌐 dba.stackexchange.com
February 6, 2012
security - Is there some kind of "undo" or "rewind" feature in PostgreSQL? - Database Administrators Stack Exchange
Although it has not actually happened in quite a long time, every day, I fear that I will make a mistake such as accidentally deleting the wrong table, or deleting too many records, or doing some k... More on dba.stackexchange.com
🌐 dba.stackexchange.com
sql - Restore deleted records in PostgreSQL - Stack Overflow
0 How to rollback my delete data in Postgres after delete operation? More on stackoverflow.com
🌐 stackoverflow.com
recovery - Recover PostgreSQL database data - Database Administrators Stack Exchange
If you don't find any recovery ... in PostgreSQL 7.x; "Database Physical Storage" in the upcoming 8.0). You can find out which files hold a table's data by querying pg_database and pg_class. ... In front of DML statements you need write "begin;" .In execution time you need to execute with DML statement along with begin .Then execute rollback statement · EXAMPLE:- step1:- BEGIN; DELETE FROM TABLE_NAME ... More on dba.stackexchange.com
🌐 dba.stackexchange.com
🌐
PostgreSQL
postgresql.org › docs › 9.4 › sql-rollback.html
PostgreSQL: Documentation: 9.4: ROLLBACK
February 13, 2020 - You may want to view the same page for the current version, or one of the other supported versions listed above instead. ... ROLLBACK rolls back the current transaction and causes all the updates made by the transaction to be discarded.
🌐
PostgreSQL
postgresql.org › message-id › Pine.BSI.3.91.990902162726.8793P-100000@access1.lan2wan.com
PostgreSQL: Re: [SQL] Undo A Delete
September 2, 1999 - Use transactions (BEGIN, COMMIT, ROLLBACK, etc.) If you delete data inside of a transaction and then rollback, your data will be restored.
🌐
TutorialsPoint
tutorialspoint.com › postgresql › postgresql_transactions.htm
PostgreSQL - TRANSACTIONS
ROLLBACK − To rollback the changes. Transactional control commands are only used with the DML commands INSERT, UPDATE and DELETE only.
🌐
Bytebase
bytebase.com › blog › guides › postgres rollback explained
Postgres Rollback Explained | Bytebase
September 4, 2025 - Once a bad UPDATE, DELETE, or INSERT is committed, transaction rollback is gone and PITR is overkill. What you actually want is compensating DML: new statements that put the previous values back.
🌐
GeeksforGeeks
geeksforgeeks.org › postgresql-rollback
PostgreSQL - ROLLBACK - GeeksforGeeks
October 14, 2024 - Explanation: in this example, the changes are reverted to the original state after the ROLLBACK command. PostgreSQL ROLLBACK command is to undo changes made during a transaction.
Find elsewhere
🌐
CYBERTEC PostgreSQL
cybertec-postgresql.com › home › recovering deleted data from postgresql tables
Recovering Deleted Data From PostgreSQL Tables
December 3, 2025 - You could now perform a Point In Time Recovery (PITR) to a timestamp just before the undesirable DELETE command. Let's say options 1 and 2 failed, and we really have to recover the data from the running PostgreSQL instance. The good news is that DELETE does not actually delete data, it just marks it as invisible for subsequent transactions.
🌐
EnterpriseDB
enterprisedb.com › postgres-tutorials › how-work-postgresql-transactions
How to work with PostgreSQL transactions | EDB
As the name suggests, ROLLBACK undoes the changes that were issued in the transaction block before it. postgres=# begin; BEGIN postgres=# delete from test; DELETE 1 postgres=# drop table test; DROP TABLE postgres=# rollback; ROLLBACK postgres=#
🌐
O'Reilly
oreilly.com › library › view › practical-postgresql › 9781449309770 › ch14s59.html
Rollback - Practical PostgreSQL [Book]
booktown=# BEGIN WORK; BEGIN booktown=# DELETE FROM shipments; DELETE 36 booktown=# ROLLBACK WORK; ROLLBACK
🌐
PostgreSQL
postgresql.org › docs › current › sql-delete.html
PostgreSQL: Documentation: 18: DELETE
May 14, 2026 - WITH delete_batch AS ( SELECT l.ctid FROM user_logs AS l WHERE l.status = 'archived' ORDER BY l.creation_date FOR UPDATE LIMIT 10000 ) DELETE FROM user_logs AS dl USING delete_batch AS del WHERE dl.ctid = del.ctid; This use of ctid is only safe because the query is repeatedly run, avoiding the problem of changed ctids. This command conforms to the SQL standard, except that the USING and RETURNING clauses are PostgreSQL extensions, as is the ability to use WITH with DELETE.
🌐
Reddit
reddit.com › r/postgresql › do you run update and delete statements in transactions?
r/PostgreSQL on Reddit: Do you run update and delete statements in transactions?
September 24, 2022 -

I always do but I have seen plenty of developers and dbas don’t in production. It makes me cringe sometimes. If you are those people, can you tell me why? Are you worried about table locking?

🌐
PostgreSQL
postgresql.org › message-id › web-492035@davinci.ethosmedia.com
PostgreSQL: Re: undo delete w/ transaction?
October 25, 2001 - 2. You can't distinguish the records you just deleted from records you may have deleted, on purpose, earlier, or older versions of records you updated. 3. Restoring a whole table in this form would require a custom text parsing program to re-build the table source into a COPY file. If you're ready for all that, then: 1. Go to <postgresql directory>/pgsql/data/ 2.
🌐
Postgres Professional
postgrespro.com › list › thread-id › 2120897
Thread: Rollback in Postgres : Postgres Professional
> Iam surprised iam not able to find the same in postgres. If you were not in a query, then you cannot just roll back. This is because each statement is an individual transaction and a delete query "outside" a transaction is actually a begin;delete...;commit; in nature. Oracle only supports the rollback after commit if you have the right module installed and activated.