Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

-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
share|improve this answer
 
Thanks Mingyu... –  Rafiu Nov 22 at 7:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.