Move a table to another schema - Mailing list pgsql-general

From Lee Kindness
Subject Move a table to another schema
Date
Msg-id 16312.61872.303145.799444@kelvin.csl.co.uk
Whole thread Raw
Responses Re: Move a table to another schema  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
Re: Move a table to another schema  (Andrew Rawnsley <ronz@ravensfield.com>)
List pgsql-general
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.

pgsql-general by date:

Previous
From:
Date:
Subject: Re: Alternative cluster location
Next
From: Peter Eisentraut
Date:
Subject: Re: Alternative cluster location