Re: How to copy a schema under another name in same database

From: "Daniel Gour" <Daniel(dot)Gour(at)adacel(dot)com>
To: "Frank Bax" <fbax(at)sympatico(dot)ca>
Cc: "PostgreSQL List - Novice" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: How to copy a schema under another name in same database
Date: 2008-07-30 17:04:42
Message-ID: 6B0B2B2B3D1F634F99AD4D99BA30A20B02FEE93A@adacel-mail.adacelcanada.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Thanks for the suggestion, but I need the application to be multi-platform
(I'm using Qt). Since sed is not natively available on XP... Also, as you
mention, it is risky to blindly replace one string for another in the whole
sql script.

The solution is however simple and elegant, maybe someone else will find it
useful. Thanks!

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

-----Original Message-----
From: Frank Bax [mailto:fbax(at)sympatico(dot)ca]
Sent: Wednesday, July 30, 2008 12:51 PM
To: PostgreSQL List - Novice
Subject: Re: [NOVICE] How to copy a schema under another name in same
database

Daniel Gour wrote:
> 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?

Backup the schema with pg_dump; edit file; change schema name and
restore? If schema names do not show up in data; then this might work:

pg_dump ... | sed s:schema1:schema2:g | psql

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Rodrigo E. De León Plicet 2008-07-30 20:08:21 Re: How to copy a schema under another name in same database
Previous Message Frank Bax 2008-07-30 16:51:07 Re: How to copy a schema under another name in same database