Re: Moving tables between schemas

From: Shridhar Daithankar <shridhar(at)frodo(dot)hserus(dot)net>
To: John Sidney-Woollett <johnsw(at)wardbrook(dot)com>
Cc: "m(dot)e(dot)bruche(at)lse(dot)ac(dot)uk" <m(dot)e(dot)bruche(at)lse(dot)ac(dot)uk>, postgres general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Moving tables between schemas
Date: 2004-07-30 10:48:13
Message-ID: 200407301618.13632.shridhar@frodo.hserus.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Friday 30 Jul 2004 3:49 pm, John Sidney-Woollett wrote:
> You may be able to play around with the system catalogs, but I don't
> know anything about that...
>
> An easy method of moving the tables are
>
> create table mynewschema1.table1 as select * from public.table1;
> drop public.table1;
>
> create table mynewschema2.table2as select * from public.table2;
> drop public.table2;

One can also create a table before hand using 'create table like' and then
inserting rows. This has advantage of preserving any constraints in original
table.

But this does not take care of indexes AFAIK.

Shridhar

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jason Tesser 2004-07-30 11:27:49 Re: Wal logs
Previous Message John Sidney-Woollett 2004-07-30 10:42:58 Re: Moving tables between schemas