Re: Move a table to another schema
Andrew Rawnsley <ronz@ravensfield.com>
From: Andrew Rawnsley <ronz@ravensfield.com>
To: Lee Kindness <lkindness@csl.co.uk>
Cc: pgsql-general@postgresql.org
Date: 2003-11-17T17:42:33Z
Lists: pgsql-general
I would imagine the safest way would be to recreate the table in the new schema and do a INSERT INTO ...SELECT * FROM .... Not elegant, but perfectly safe. You mess with the pg_* catalogs at your own risk. On Nov 17, 2003, at 11:05 AM, Lee Kindness wrote: > I have many tables created in the "public" schema and I would like to > migrate these into an "x001" schema. Unfortunately there is no ALTER > TABLE construct for this... The following SQL would seem to move the > "zxc" table from "public.zxc" to "x001.zxc": > > UPDATE pg_class > SET relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = > 'x001') > FROM pg_namespace > WHERE pg_class.relname = 'zxc' AND > pg_namespace.nspname = 'public' AND > pg_class.relnamespace = pg_namespace.oid > > Has anyone else addressed this before? Recommendations? > > Thanks, L. > > ---------------------------(end of > broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html > -------------------- Andrew Rawnsley President The Ravensfield Digital Resource Group, Ltd. (740) 587-0114 www.ravensfield.com