Re: Moving tables between schemas

From: "m(dot)e(dot)bruche(at)lse(dot)ac(dot)uk" <m(dot)e(dot)bruche(at)lse(dot)ac(dot)uk>
To: John Sidney-Woollett <johnsw(at)wardbrook(dot)com>
Cc: postgres general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Moving tables between schemas
Date: 2004-07-30 11:39:30
Message-ID: 1091187570.29765.31.camel@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks. I hadn't thought of that - that's probably easiest.

On Fri, 2004-07-30 at 10:19, 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;
>
> You may need to recreate any indexes that the tables used in the public
> schema, and you may need to grant rights in order to allow your users to
> access the tables...
>
> Hope that helps
>
> John Sidney-Woollett
>
> create
>
> m(dot)e(dot)bruche(at)lse(dot)ac(dot)uk wrote:
> >
> > Hi,
> >
> > In my database, I created a lot of tables before I found out about
> > schemas. It's a mess!
> >
> > Suppose I want to get organised, and create a couple of schemas. How do
> > I move existing tables into my newly created schemas?
> >
> > e.g.
> >
> > public.table1 -> mynewschema1.table1
> > public.table2 -> mynewschema2.table2
> >
> > ?
> >
> > Thanks.
> >
> > Max
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rodríguez Rodríguez, Pere 2004-07-30 11:52:01 pg_restore -t
Previous Message Jason Tesser 2004-07-30 11:27:49 Re: Wal logs