4

I am currently working on a project where I need to do an SQL request that can clone a database (postgres) without any data (only schema a.k.a only the columns of the different tables and constraint like primary key/foreign key).

Some topic are similar to my question like this two : Creating a copy of a database in PostgreSQL and Backup of PostgreSQL database design - without data but they use pg_dump in command line or TEMPLATE function that include all data of my orignal DB.

Is there a way of using it in an SQL request or use a specific option of CREATE DATABASE to clone without data ? Thank you

2
  • 1
    PG_DUMP -s (schema only) there are various commands to determine which elements you need to copy Commented Feb 15, 2019 at 14:53
  • No, that cannot be done in SQL. pg_dump -s is your best bet. Don't use the postgres database to store data in it. Commented Feb 15, 2019 at 14:53

0

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.