Re: Changing schemas

From: Sim Zacks <sim(at)compulab(dot)co(dot)il>
To: Naz Gassiep <naz(at)mira(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Changing schemas
Date: 2006-09-19 05:49:50
Message-ID: 183891045.20060919074950@compulab.co.il
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Try renaming the schema. alter schema schemaname rename to newname;
then if you want the old schema back create a new one.

If there are already stuff in the schema you want to move to then
write a quick function using a for loop with the pg_class table
to write the alter table statement for anything that has the
schema you are looking for.

Sim Zacks
IT Manager
CompuLab
04-829-0145 - Office
04-832-5251 - Fax

________________________________________________________________________________

I need a single command to change ALL objects

Something like "alter table (select name from tables where schema =
'foo') set schema bar"

Sim Zacks wrote:
> ALTER TABLE name
> SET SCHEMA new_schema
>
>
> Naz Gassiep wrote:
>> Is there a way to change the schema that all objects are in?
>> Essentially I want to move everything currently in the database into
>> public rather than having the complex schemas that I have at the
>> moment. They are unnecessary and the DB complexity is trivial, so
>> using schema partitioning is more trouble than it is worth. Is there
>> a way I can do this? I tried editing a dump, but that has proven to
>> be a little difficult, as I am not a master of regex.
>>
>> If I can do it from within the DB before I do the dump that'd be
>> easier. Is there a way to do this from within the DB?
>>
>> Thanks,
>> - Naz.
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 1: if posting/reading through Usenet, please send an appropriate
>> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
>> message can get through to the mailing list cleanly
>>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Hagander 2006-09-19 07:52:26 Re: vista
Previous Message Najib Abi Fadel 2006-09-19 05:33:30 Re: What is the Best Postgresql Load Balancing Solution available ?