Let us assume there's a database name myDataBase. There are four schema in this database named

1: schema_1

2: schema_2

3: schema_3

4: schema_4

I have created a dump of schema_1 from this command pg_dump myDataBase --schema=schema_1 > schema_1_dump

How to import schema_1_dump to only schema_3 but not to any other schema

probably the easiest is to first rename the existing schema_1

restore the dump

rename the new schema_1 to schema_3

restore the original schema_1 to its original name

eg psql:

 alter schema schema_1 rename to schema_1_backup;
 create schema schema_1;
 \i schema_1_dump
 drop schema_3 cascade;
 alter schema schema_1 rename to schema_3;
 alter schema schema_1_backup rename to schema_1;

This is going to annoy other users.

The other way is to change all the SQL commands to say 'schema3' instead of 'schema1'

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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