Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL export only the schema structure

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

like image 918
Visahan Avatar asked Mar 15 '16 05:03

Visahan


1 Answers

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> 
like image 168
Sandeep Sukhija Avatar answered Sep 30 '22 20:09

Sandeep Sukhija