How to duplicate schemas in PostgreSQL

You can probably do it from the command line without using files:

pg_dump -U user --schema="fromschema" database | sed 's/fromschmea/toschema/g' | psql -U user -d database

Note that this searches and replaces all occurrences of the string that is your schema name, so it may affect your data.

Leave a Comment

File not found.