Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create dump for specific schema in postgres DB

I have a Postgres database "rafiu" with many schemas namely test1, test2, test3. In this I want to dump the test2 schema and its data. I tried with the following query

pg_dump -U postgres -n test2 -t t1 -t t2 rafiu > test_schema.sql

but it dumped public.t1, public.t2 tables instead of test2 schema tables in the resultant dump file.

Kindly suggest me how to create a dump specific specific schema in a DB.

Thanks in advance.

like image 382
Rafiu Avatar asked Nov 22 '13 07:11

Rafiu


1 Answers

-n test2 means to dump schema test2.

If you want to dump table test2.t1 and test2.t2, you might want to try the following statement:

pg_dump -U postgres -t test2.t1 -t test2.t2 rafiu > test_schema.sql
like image 158
Mingyu Avatar answered Oct 06 '22 17:10

Mingyu