Skip site navigation (1) Skip section navigation (2)

How to copy a schema under another name in same database

From: "Daniel Gour" <Daniel(dot)Gour(at)adacel(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: How to copy a schema under another name in same database
Date: 2008-07-29 13:20:21
Message-ID: 6B0B2B2B3D1F634F99AD4D99BA30A20B02FEE936@adacel-mail.adacelcanada.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hello!  I have a PostgreSQL (8.3.3, WinXP + linux) database with multiple
schemas.  I would like, on a regular basis, to be able to copy the structure
and data of one schema under a new schema, using of course a different name.
What would be the easiest way?

 

-          I have seen the TODO entry "Add CREATE SCHEMA ... LIKE that copies
a schema", so I guess an easy solution (a single pgsql command) is not yet
available...

 

-          I guess the alternative is to use pg_dump to dump a single schema
and use pg_restore, but how can I restore the dumped information under
another schema?  I would like to avoid dumping it as an sql script and having
it to modify it manually, because this will be a regular operation that I
would like to automate in my application.

 

Thanks in advance for any insight you can provide!

---------------------------------
Daniel Gour
Adacel Inc.



 

Responses

pgsql-novice by date

Next:From: Bastiaan OlijDate: 2008-07-29 23:05:37
Subject: Re: How to copy a schema under another name in same database
Previous:From: Charles SimardDate: 2008-07-24 17:14:41
Subject: Re: CANNOT CREATE A TABLESPACE

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group