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?

2
  • 1
    are you trying to export the schema? if so stackoverflow.com/questions/14486241/… Commented Nov 19, 2015 at 18:13
  • @FuzzyTree thanks, your comment helped me. Commented Nov 19, 2015 at 20:56

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.