Re: New DBs from existing schemas

From: Chris <dmagick(at)gmail(dot)com>
To: nishad(at)ptolemy(dot)tlg(dot)uci(dot)edu
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: New DBs from existing schemas
Date: 2006-05-25 03:55:00
Message-ID: 44752A94.5050009@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Nishad Prakash wrote:
> I want to create a new database with the exact schema of an existing one,
> but a different name. After some reading, it seems
>
> pg_dump -s old_db > old_schema

That will dump all schemas from that db. If you only want a particular
schema, use '-n'.

> createdb -t old_schema new_db

There is no '-t' at least in 8.1.1..

'-T' on the other hand lets you specify an existing db and it will use
that as a base instead of template1.

> should work. Will it? Note that old_db has lots of stored functions and
> user-defined operators in addition to tables and indices.

You could just use the first database as a template (using '-T') for the
second one and that will copy everything across but that includes your data.

> Also, is there any way to selectively restore some of the data from old_db
> into new_db as well? I'll settle for all data if selectivity isn't
> possible. Here, I don't have any good guesses, as the docs for pg_restore
> don't say anything specific about restoring into a db other than the one
> dumped from.

You can dump particular tables only but you don't get anything more
selective.

--
Postgresql & php tutorials
http://www.designmagick.com/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Patrick TJ McPhee 2006-05-25 04:38:16 Re: psql \echo strangeness with :variables
Previous Message Chris Velevitch 2006-05-25 03:36:35 Re: How to estimate disk space