views:

1059

answers:

3

Is there a simple way to create a copy of a database or schema in PostgreSQL 8.1?

I'm testing some software which does a lot of updates to a particular schema within a database, and I'd like to make a copy of it so I can run some comparisons against the original.

+6  A: 

pg_dump with the --schema-only option. (Link goes to 7.4 docs but if you just Google pg_dump you will get links to every version)

Matt Kane
Replace "7.4" with "current" and you have a link to the latest version.
bortzmeyer
A: 

here is a link to some examples of backing up and restoring. You can use the backup to restore to a different server or whatever

northpole
+3  A: 

If it's on the same server, you just use the CREATE DATABASE command with the TEMPLATE parameter. For example:

CREATE DATABASE newdb WITH TEMPLATE olddb;
Jordan S. Jones
Thanks, that did the trick.
Jin Kim