0

How to generate the "create table" sql statement for an existing table in postgreSQL Here is explained how to generate such script for one table, but how to do the same for whole database?

Community
  • 1
  • 1
serhii
  • 1,135
  • 2
  • 12
  • 29

1 Answers1

0

I need to extract the script that creates the database and all tables in it.

pgdump -s databasename does this

pgdump -s databasename | awk 'RS="";/TABLE[^;]*;/' allows extract statements of table creating/altering. Unfortunately I don't understand awk syntax.

serhii
  • 1,135
  • 2
  • 12
  • 29