Move a table to another schema

Lee Kindness <lkindness@csl.co.uk>

From: Lee Kindness <lkindness@csl.co.uk>
To: pgsql-general@postgresql.org
Cc: Lee Kindness <lkindness@csl.co.uk>
Date: 2003-11-17T16:05:04Z
Lists: 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.