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

Creating schema copy

From: Mariusz Czułada <manieq(at)idea(dot)net(dot)pl>
To: pgsql-general(at)postgresql(dot)org
Subject: Creating schema copy
Date: 2004-10-27 23:24:06
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general

In a database I have to create new schemas with exactely the same structure as 
the default one. Of course, I could reverse a schema with pg_dump, then apply 
the script to the newly created one. The problem is the base schema sometimes 
changes so I should generate scripts every time. Also I need to do this from 
a stored function.

My question: is it possible to extend (in near future) CREATE SCHEMA syntax 
with feature like:
	CREATE SCHEMA user_xxx_schema FROM default_user_schema [WITH CONTENT];
It should create *every* object existing in 'default_user_schema' in 
'user_xxx_schema' preserving of course names, constraints, triggers, etc. 
Optionally it could also copy table contents (but this is not very 

Or is there any other (relatively simple and safe) way do do this *inside* a 
stored function (pl/pgsql)?




pgsql-general by date

Next:From: Tom LaneDate: 2004-10-27 23:24:51
Subject: Re: WARNING: column "footype" has type "unknown"
Previous:From: Ed L.Date: 2004-10-27 23:01:45
Subject: WARNING: column "footype" has type "unknown"

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