Re: Explicitly adding a table to a schema. - Mailing list pgsql-general

From Adam Cornett
Subject Re: Explicitly adding a table to a schema.
Date
Msg-id CAB5sPxaT+0FH5E_wvx63B6gEv7SxY8A=0bCR1d9gu2c+4X0gJA@mail.gmail.com
Whole thread Raw
In response to Explicitly adding a table to a schema.  (thatsanicehatyouhave@mac.com)
Responses Re: Explicitly adding a table to a schema.  (Demitri Muna <thatsanicehatyouhave@mac.com>)
List pgsql-general

On Fri, Nov 4, 2011 at 1:57 PM, <thatsanicehatyouhave@mac.com> wrote:
Hi,

I have a database where I wasn't explicitly using schemas when I started it (i.e. everything was simply under "public"). I've since created several schemas and renamed the "public" schema to something else. When I look at the definitions (in PGAdmin III), the CREATE statement for the old tables look like this:

CREATE TABLE foo ( ...

whereas for my newer tables the full schema path is there:

CREATE TABLE myschema.bar ( ...

Is there a way that the explicit schema can be added to my older tables? The reason I want to do this is that I'm having a problem with external code (SQLAlchemy) when trying to get foreign key information through reflection-- the table doesn't seem to be found.

Does this even make sense since the tables are definitely in the new schema anyway?

Cheers,
Demitri

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


You can use ALTER TABLE (http://www.postgresql.org/docs/current/static/sql-altertable.html) to set the schema of existing tables:
ALTER TABLE foo SET SCHEMA bar

-Adam

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: psql is too slow to connect
Next
From: Tom Lane
Date:
Subject: Re: Excessive planner time for some queries with high statistics