Re: New DBs from existing schemas - Mailing list pgsql-general

From Chris
Subject Re: New DBs from existing schemas
Date
Msg-id 44752A94.5050009@gmail.com
Whole thread Raw
In response to New DBs from existing schemas  (Nishad Prakash <prakashn@uci.edu>)
List 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/

pgsql-general by date:

Previous
From: "Chris Velevitch"
Date:
Subject: Re: How to estimate disk space
Next
From: Michael Ben-Nes
Date:
Subject: Re: I dont get it,