Move table between schemas

Move table between schemas

am 16.11.2004 10:02:34 von schabios

Hello,

Is there an easy way to move a table to another schema in PostgreSQL 7.4?

ALTER TABLE and ALTER SCHEMA don't have this options.

Thanks,
Markus
--=20
markus schaber | dipl. informatiker
logi-track ag | rennweg 14-16 | ch 8001 zürich
phone +41-43-888 62 52 | fax +41-43-888 62 53
mailto:schabios@logi-track.com | www.logi-track.com

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Re: Move table between schemas

am 16.11.2004 12:05:38 von ajs

On Tue, Nov 16, 2004 at 10:02:34AM +0100, Markus Schaber wrote:
> Hello,
>
> Is there an easy way to move a table to another schema in PostgreSQL 7.4?
>
> ALTER TABLE and ALTER SCHEMA don't have this options.

CREATE TABLE newschema.newtable AS SELECT * FROM oldschema.oldtable

oughta work.

A

--
Andrew Sullivan | ajs@crankycanuck.ca
When my information changes, I alter my conclusions. What do you do sir?
--attr. John Maynard Keynes

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Re: Move table between schemas

am 16.11.2004 13:30:09 von achill

O Andrew Sullivan Ýãñáøå óôéò Nov 16, 2004 :

> On Tue, Nov 16, 2004 at 10:02:34AM +0100, Markus Schaber wrote:
> > Hello,
> >
> > Is there an easy way to move a table to another schema in PostgreSQL 7.4?
> >
> > ALTER TABLE and ALTER SCHEMA don't have this options.
>
> CREATE TABLE newschema.newtable AS SELECT * FROM oldschema.oldtable
>
> oughta work.

What about indexes, constraints, sequences,etc...???
>
> A
>
>

--
-Achilleus


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Re: Move table between schemas

am 16.11.2004 23:09:37 von ajs

On Tue, Nov 16, 2004 at 02:30:09PM +0200, Achilleus Mantzios wrote:
> >
> > CREATE TABLE newschema.newtable AS SELECT * FROM oldschema.oldtable
> >
> > oughta work.
>
> What about indexes, constraints, sequences,etc...???

You'll have to create those too, I'm afraid. I don't know of a way
to move tables from one schema to another otherwise. You could do
all the dependencies with a pg_dump -t, I suspect. Not tested that,
though.

A

--
Andrew Sullivan | ajs@crankycanuck.ca
A certain description of men are for getting out of debt, yet are
against all taxes for raising money to pay it off.
--Alexander Hamilton

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly