DevonDahon
DevonDahon

Reputation: 8360

PostgreSQL: How duplicate schema structure?

My goal is to create a temporary schema, fill it from big data then drop my public schema and rename the temporary schema to public, in order to reduce the time the database is unavailable.

How to duplicate schema structure into temporary schema?

Upvotes: 0

Views: 83

Answers (1)

Frank N Stein
Frank N Stein

Reputation: 2518

I never dropped public schema, but:

pg_dump --schema-only --schema=public | set '%s/public\./temporary\./g' | psql -h samehost
DROP  SCHEMA public;
ALTER SCHEMA temporary RENAME TO public;

Upvotes: 1

Related Questions