0

I want to restore postgres from the output of pg_dumpall. However I want the restore to fail if there is any data in postgres at the moment. Is there a way to check this? In other words I want my restore to work only in a completely empty db (meaning user-defined tables). My postgres version is 9.6

Nuri Tasdemir
  • 9,720
  • 3
  • 42
  • 67
  • 1
    You can check `information_schema.tables` and filter on user-defined tables. That might be sufficiently empty for you. Just so you know, a database is not really "empty", it is filled with system stuff. – Gordon Linoff Mar 20 '18 at 14:26
  • @GordonLinoff Yes, my empty definition is only regarding the user-defined tables – Nuri Tasdemir Mar 20 '18 at 14:28

1 Answers1

0

User-defined tables can be retrieved through pg_catalog.pg_stat_user_tables system view.