Move table between schemas

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
--
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 [at] logi-track.com | www.logi-track.com

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

http://archives.postgresql.org
schabios [ Di, 16 November 2004 10:02 ] [ ID #485837 ]

Re: Move table between schemas

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 [at] 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
ajs [ Di, 16 November 2004 12:05 ] [ ID #486323 ]

Re: Move table between schemas

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
achill [ Di, 16 November 2004 13:30 ] [ ID #486325 ]

Re: Move table between schemas

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 [at] 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 [at] postgresql.org so that your
message can get through to the mailing list cleanly
ajs [ Di, 16 November 2004 23:09 ] [ ID #487029 ]
Datenbanken » comp.databases.postgresql.sql » Move table between schemas

Vorheriges Thema: tree structure photo gallery date quiery
Nächstes Thema: finding gaps in dates