Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL how to create a copy of a database or schema?

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.

like image 250
Jin Kim Avatar asked Apr 30 '09 19:04

Jin Kim


1 Answers

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; 
like image 113
Jordan S. Jones Avatar answered Sep 18 '22 14:09

Jordan S. Jones