Re: Schema Names

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Derrick Betts" <derrick(at)blueaxis(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Schema Names
Date: 2006-07-29 04:48:47
Message-ID: 14368.1154148527@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Derrick Betts" <derrick(at)blueaxis(dot)com> writes:
> However, if I create a new schema, it would seem that the only way to =
> access a table within the new schema is to pre-pend the table name with =
> the schema name:
> CREATE SCHEMA new_schema;
> CREATE TABLE new_table (column_name varchar);

> SET search_path TO new_schema;
> SELECT column_name FROM new_table; This returns an error saying =
> there is no such table as new_table.

That's because you created new_table in the public schema. I think you
are confusing

CREATE SCHEMA new_schema;
CREATE TABLE new_table (column_name varchar);

(two independent commands, and the second one creates new_table in whatever
schema is current according to search_path) with

CREATE SCHEMA new_schema
CREATE TABLE new_table (column_name varchar);

which per SQL spec makes new_schema and then creates new_table within
it. That semicolon makes a lot of difference...

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Kaloyan Iliev 2006-07-29 17:51:35 Re: Tables Locks Quetion or Strictlly subsequent numbers
Previous Message Derrick Betts 2006-07-29 04:45:57 Re: Schema Names