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?

Giovanno
  • 105
  • 2
  • 7
  • 3
    There is an answer here: https://stackoverflow.com/questions/808735/postgresql-how-to-create-a-copy-of-a-database-or-schema, using `pg_dump with the --schema-only option.` – vitaly-t May 23 '18 at 08:05
  • @vitaly-t thank you, but there is no query for doing this? – Giovanno May 23 '18 at 08: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. –  May 24 '18 at 06:33
  • @a_horse_with_no_name Okay I see, thank you... – Giovanno May 24 '18 at 07:17

1 Answers1

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.

Pavel B.
  • 843
  • 1
  • 7
  • 17