You are here: Home Tech Notes General PostgreSQL: Copy Database
PostgreSQL: Copy Database PDF Print E-mail
User Rating: / 0
PoorBest 
Tech Notes - General
Written by Rick   
Wednesday, 03 March 2010 00:00

It's not uncommon to run across a need to duplicate a database for testing purposes. PostgreSQL provides for the ability to duplicate the structure and data content with a single command;

 

CREATE DATABASE newdb WITH TEMPLATE originaldb;

 

With any luck it's obvious one needs to replace "newdb" with the new database name and "originaldb" with the name of the source database.

I've executed this command in phpPgAdmin (v4.2-beta-1) with success on a 657MB database. The process took approximately 10 minutes. I have no doubt the command can be executed from the pgsql prompt as well.

PostgreSQL DB Server version 8.1.11.

Comments (0)
Write comment
Your Contact Details:
Gravatar enabled
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):S
:!::?::idea::arrow:
Security
Please input the anti-spam code that you can read in the image.