Re: Schema Names - Mailing list pgsql-novice

From Tom Lane
Subject Re: Schema Names
Date
Msg-id 14368.1154148527@sss.pgh.pa.us
Whole thread Raw
In response to Schema Names  ("Derrick Betts" <derrick@blueaxis.com>)
List pgsql-novice
"Derrick Betts" <derrick@blueaxis.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

pgsql-novice by date:

Previous
From: "Derrick Betts"
Date:
Subject: Re: Schema Names
Next
From: Kaloyan Iliev
Date:
Subject: Re: Tables Locks Quetion or Strictlly subsequent numbers