0

I have already known query to clone like:

CREATE DATABASE db_dest WITH TEMPLATE db_src OWNER postgres

But that query also cloned the data in the tables. I want to clone all tables and it's structures in the database, but not the data. How can I do this?

4
  • 3
    There is an answer here: stackoverflow.com/questions/808735/…, using pg_dump with the --schema-only option. Commented May 23, 2018 at 8:05
  • @vitaly-t thank you, but there is no query for doing this? Commented May 23, 2018 at 8:51
  • 1
    @Giovanno: no, the way through a SQL dump without data is the best option you have. Alternatively clone the database, then truncate all tables. Commented May 24, 2018 at 6:33
  • @a_horse_with_no_name Okay I see, thank you... Commented May 24, 2018 at 7:17

1 Answer 1

1

I'm not sure if is SQL comand for this. but you can try

create backoup in PGadmin and in dump option select only schema option and then restore it to new db.

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.