Re: Explicitly adding a table to a schema.

From: Adam Cornett <adam(dot)cornett(at)gmail(dot)com>
To: Demitri Muna <thatsanicehatyouhave(at)mac(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Explicitly adding a table to a schema.
Date: 2011-11-04 18:37:40
Message-ID: CAB5sPxYEDQwLGTHYAO2pomL=JWxXNPA7S28-diPB4=wxUrsHVw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Nov 4, 2011 at 2:32 PM, Demitri Muna
<thatsanicehatyouhave(at)mac(dot)com>wrote:

> Hi,
>
> On Nov 4, 2011, at 2:09 PM, Adam Cornett wrote:
>
> > 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
>
> Thanks. I did try that, but that command moves the table to a different
> schema, which is not what I'm trying to do. It struck me to try to move it
> to another schema (where the definition then explicitly included the schema
> prefix) and then move it back, but it still doesn't have the schema prefix.
>
> Cheers,
> Demitri
>

What you might be looking for then is the "search_path"
http://www.postgresql.org/docs/current/static/ddl-schemas.html#DDL-SCHEMAS-PATH
when you specify an unqualified table, Postgres uses the search path to
look for it, and when creating tables, unqualified tables go into 'public'
which is the default search path.

I'm not sure if you get pgadmin to add "public" to the create table
statements, pg_dump might though.

-Adam

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2011-11-04 18:39:56 Re: Explicitly adding a table to a schema.
Previous Message Demitri Muna 2011-11-04 18:32:53 Re: Explicitly adding a table to a schema.