Re: Programmatically duplicating a schema - Mailing list pgsql-general

From Melvin Davidson
Subject Re: Programmatically duplicating a schema
Date
Msg-id CANu8Fiy3BCDi77ZDDKmscCnYaAvgtPKNSqx+Ks2xVpC3TUCa+A@mail.gmail.com
Whole thread Raw
In response to Re: Programmatically duplicating a schema  (Alban Hertroys <haramrae@gmail.com>)
List pgsql-general
 > What is a reliable way to programmatically & generically populate an empty schema with all the objects in the public schema as a template?

The simplest way is just to load the attached clone_schema function. It was originally created by Emanuel '3manuek', which I enhanced. It
now copies all sequences, tables, indexes, rules, triggers, data(optional), views & functions from any existing schema to a new schema.

Then just call the function.

SAMPLE CALL:
SELECT clone_schema('public', 'new_schema', TRUE);

Use FALSE if you do not want to copy data.


--
Melvin Davidson
Maj. Database & Exploration Specialist

Universe Exploration Command – UXC

Employment by invitation only!
Attachment

pgsql-general by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Point-in-time recovery after failover
Next
From: Melvin Davidson
Date:
Subject: Re: UPSERT on a view