5

After running a query like

 delete from table tablename

Can the records be recovered? From what I know Postgresql is just marking the records as deleted.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Valentin Brasso
  • 1,388
  • 7
  • 21
  • 41
  • 1
    I wrote a more detailed answer about this on another question. See http://stackoverflow.com/questions/12472318/can-i-rollback-a-transaction-ive-already-committed-data-loss/12472582#12472582 – Craig Ringer Oct 14 '12 at 10:42

1 Answers1

3

Try pg file dump.

Source.

EDIT: In the Postgres Wiki you can find the pg file dump git repository.

Maicon Mauricio
  • 2,052
  • 1
  • 13
  • 29
Denis de Bernardy
  • 75,850
  • 13
  • 131
  • 154
  • thank you! Do you have any more details? I would like to access a specific table on a spacific database and after reading the source (there is no other documentation) i'm not really sure how to proceed. Also, this is a production database. – Valentin Brasso May 27 '11 at 11:52
  • 1
    I'm afraid not. Your question prompted me to google it. It's being maintained by Tom Lane, though, so chances are he'll reply himself if you ask for help on the pg-hackers list. – Denis de Bernardy May 27 '11 at 11:54
  • If you need help that doesn't involve actually hacking the code, ask your question on pgsql-general, not hackers. -hackers is for hacking code, not asking for support. – Scott Marlowe May 28 '11 at 11:17
  • 1
    You should also check out `pg_dirtyread`. See http://stackoverflow.com/questions/12472318/can-i-rollback-a-transaction-ive-already-committed-data-loss/12472582#12472582 – Craig Ringer Oct 14 '12 at 10:43
  • 1
    The links don't seem to be working any more. Is there an updated link, or an alternative way of doing this? – spinningarrow Feb 08 '17 at 07:56
  • @spinningarrow: this answer is from years ago, but try: http://pgsql-hackers.postgresql.narkive.com/xP51LFSQ/how-to-make-a-pg-filedump and https://wiki.postgresql.org/wiki/Pg_filedump – Denis de Bernardy Feb 17 '17 at 18:58