Cloning Schemas - PostgreSQL

Doing research on how to clone a PostgreSQL 9.3 schema within the same database. Everything seems to be pointing to doing some command line work with pg_dump, wondering if anyone has any experience with this?

Thanks

BTW - just in case anyone is not aware you can clone a database with

CREATE DATABASE newdatabase WITH TEMPLATE templatedb OWNER dbuser;

Suppose I’m really looking for an equivalent for schemas!

I believe that you can do a backup via pgAdmin with the schema only. Of course the pgAdmin is just a front for the pg command line operations.

Thanks Kevin - yep, seems it’s either go to the command line or build one hell of a function to move things about.

I’m going to work with different databases as opposed to different schemas - far simpler and safer.

One thing that I was considering is that some hosting services will give you 1 database, unlimited schemas, unlimited tables. For lower end customers, it’s nice to be able to keep their one database, and just add my new schema to the mix. Keeps things cheaper for them. Just a small nit.

good job I’m not on shared hosting then :wink: