Re: Move a table to another schema
От | Andrew Rawnsley |
---|---|
Тема | Re: Move a table to another schema |
Дата | |
Msg-id | 6CCDCF95-1925-11D8-BA13-000393A47FCC@ravensfield.com обсуждение исходный текст |
Ответ на | Move a table to another schema (Lee Kindness <lkindness@csl.co.uk>) |
Список | 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
В списке pgsql-general по дате отправления: