-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of srilinux
Sent: Friday, July 21, 2017 3:29 PM
To: pgsql-sql@postgresql.org
Subject: [SQL] How to duplicate postgres 9.4 database
Hi All
I want to duplicate the existing database , after reading documentation I used below command which just created
database,but did not create data
CREATE DATABASE standby TEMPLATE template0;
my database is 35gb so dump and psql will take longer hours
is there an fastest way to copy database on same server , so that I can just modify pointing to the database and
connectto the stanby one to do any testing ?
__________________________________________________________________________________________________________
As a TEMPLATE you should use the db that you want to copy, let's call it "source_db":
CREATE DATABASE standby TEMPLATE source_db;
Be aware, that when this statement runs there should be no user connections to source_db.
Regards,
Igor Neyman