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?
Asked
Active
Viewed 2,487 times
0
-
1are you trying to export the schema? if so http://stackoverflow.com/questions/14486241/how-can-i-export-the-schema-of-a-database-in-postgresql – FuzzyTree Nov 19 '15 at 18:13
-
@FuzzyTree thanks, your comment helped me. – serhii Nov 19 '15 at 20:56
1 Answers
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