7

I have a Database which has multiple schema, I need to export one of those schema structure to an sql file without the data. Is this possible, if so What command should I use?

When I use this command, I get the data as well, but I have a lot of data which makes the server run out of space for this.

--host xx --port xx --username "xx" --password  --format plain --verbose --file "sample.sql" --schema "sample" "main"

I need the structure to restore it in another location. Where I do not need the data but only the structure

I'm quite new to this area, thanks for the help

Visahan
  • 1,130
  • 2
  • 14
  • 35
  • 1
    Possible duplicate of [How can I export the schema of a database in PostgreSQL?](https://stackoverflow.com/questions/14486241/how-can-i-export-the-schema-of-a-database-in-postgresql) – Huseyin Yagli Mar 22 '18 at 21:29

1 Answers1

12

Use can use pg_dump with the option -s. Follow the link pg_dump help

To extract the schema for a single database, use

pg_dump -s <schema_name> 
Sandeep Sukhija
  • 1,156
  • 16
  • 30