Skip site navigation (1) Skip section navigation (2)

Re: schema name in the SQL statement.

From: Bosco Rama <postgres(at)boscorama(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: schema name in the SQL statement.
Date: 2008-08-20 16:39:55
Message-ID: 48AC48DB.6020603@boscorama.com (view raw or flat)
Thread:
Lists: pgsql-interfaces
Masis, Alexander (US SSA) wrote:
> My db has one schema. In fact I deleted the default "public" and created
> my own: "schema_1".
> In my SQL query I have to explicitly specify schema name:
> "select my_colomn from schema_1.table_name;"
> Can't schema be specified as default value during connection, or can I
> set the schema before I send the query?

After the connection is established, set the search_path to be your
schema:
   "set search_path to schema_1;"

At that point you can use unqualified relation references again:
   "select my_colomn from table_name;"


Bosco.

In response to

pgsql-interfaces by date

Next:From: Bosco RamaDate: 2008-08-20 16:45:53
Subject: Re: ecpg 'set' failure using host vars
Previous:From: Alvaro HerreraDate: 2008-08-20 12:59:57
Subject: Re: schema name in the SQL statement.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group