Re: clone_schema function

From: Melvin Davidson <melvin6925(at)gmail(dot)com>
To: Igor Neyman <ineyman(at)perceptron(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: clone_schema function
Date: 2015-09-09 20:48:15
Message-ID: CANu8FizQ0+UA3skWiF2w-yiNa0r1+fJS+RFi969yQSAFrXHtJg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks Igor,

hmm, apparently the "INCLUDING CONSTRAINTS' option of "CREATE TABLE' has a
glitch and only includes the primary key.
I also noticed that INCLUDING ALL generates an error, so I'll have to
report that also.

I'll go eat some crow and work on a fix to add all constraints in the
meantime.

On Wed, Sep 9, 2015 at 3:43 PM, Igor Neyman <ineyman(at)perceptron(dot)com> wrote:

>
>
>
>
> *From:* pgsql-general-owner(at)postgresql(dot)org [mailto:
> pgsql-general-owner(at)postgresql(dot)org] *On Behalf Of *Melvin Davidson
> *Sent:* Wednesday, September 09, 2015 12:31 PM
> *To:* pgsql-general(at)postgresql(dot)org
> *Subject:* [GENERAL] clone_schema function
>
>
>
>
> I noted there was an inquiry as to how to copy or clone_schema
> an entire schema. The standard method for doing that is to
> 1. pg_dump the schema in plain format
> 2. edit the dump file and change all occurrences of the schema name
> 3. reload the dump into the new schema.
>
> The attached function is an alternate method for doing that.
> It is a revision of the clone_schema by by Emanuel '3manuek'
> from https://wiki.postgresql.org/wiki/Clone_schema
>
> Originally, it did not copy views, functions or data from
> the source schema despite the claim that it "copies everything".
>
> I've added error checking and verified that it now copies the
> current sequnce values, table data, views and functions.
>
> As always, use with caution.
> --
>
> *Melvin Davidson*
>
>
>
> I assume you are aware that this script does not produce complete copy of
> the source schema.
>
> Foregn Key constraints are not recreated along with the tables.
>
>
>
> Regards,
>
> Igor Neyman
>
>
>
>
>

--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christian Ramseyer 2015-09-09 21:54:26 GIN Trigram Index Size
Previous Message Igor Neyman 2015-09-09 19:43:08 Re: clone_schema function