Re: cloning database

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: Philipp Kraus <philipp(dot)kraus(at)flashpixx(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: cloning database
Date: 2014-09-19 07:12:20
Message-ID: 99E6AC27-EF0D-41D7-88FA-C25FA6B4B47B@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 19 Sep 2014, at 8:35, Philipp Kraus <philipp(dot)kraus(at)flashpixx(dot)de> wrote:

> Hello,
>
> I need around 150 copies of a database (for an exam). I have got a database with tables and data and for my exam I would copy this database in his way:
>
> database_source
>
> database1
> database2
> ….
> database150
>
> Is there a buildin way to clone the "database_source" with all structure and data into a new database "database1..150" ?

There is. You can use database_source as the template for creating new databases. There are a few restrictions, like the template database not being active, for example. See the docs for CREATE DATABASE and the createdb command.

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2014-09-19 07:13:12 Re: How can i monitor exactly what (partition) tables are accessed by a query?
Previous Message David G Johnston 2014-09-19 07:04:39 Re: Reserved keywords and qualified identifiers