I am using PostgreSQL in my project, Now by mistake I have deleted some records of one of my tables. Now is there any way to recover deleted Records in PostgreSQL?
2 Answers
May be this can help How to recover deleted records where Michael Fuhr says:
If you haven't VACUUMed the database then the deleted rows are probably still there. I don't know if any recovery tools exist, but to have any chance of recovering the data make a filesystem backup of $PGDATA as soon as possible, or at least make a backup of the table's file(s) (see below). They might not do you any good, but you'll probably need those files if you do find any recovery tools.
If you don't find any recovery tools and you really need to get the data back, then you might enjoy reading the chapter describing page file formats in the documentation ("Page Files" 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 WHERE (CONDITION); setp2:- ROLLBACK;