1

I'm using Postgres 13 & recently dropped a table with cascade on to drop all indexes, etc.

It turns out we had an old view that was tied to that table, and we need to recover the view or at least recover the query in the view to use it on a new table we are going to create.

Is it possible to recover the SQL text or do a flashback like oracle has but in Postgres?

4
  • Get it from your source control system (e.g. git) where all your code is stored
    – user1822
    Jan 12 at 18:34
  • So we do have a backup of the schema, but pg_dump doesn't include views, it looks like.
    – Jose Lopez
    Jan 12 at 19:13
  • 1
    pg_dump includes view, unless you went out of your way to exclude them. Is that your only back up, or do you have others? You can restore a physical backup on a temp server, then dump the view definition out of that.
    – jjanes
    Jan 13 at 3:35
  • If you have a plain format backup and know the name of the view, just use an editor like vim to find the CREATE VIEW statement. Jan 15 at 10:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.