how to create dump for specific schema in postgres DB

pg-dump, postgresql

Solution

`-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

Problem

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.

Original source