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

Re: schema name in the SQL statement.

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: "Masis, Alexander (US SSA)" <alexander(dot)masis(at)baesystems(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: schema name in the SQL statement.
Date: 2008-08-20 12:59:57
Message-ID: (view raw, whole thread or download thread mbox)
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?

You can change the database so that everybody connecting to it will use
that schema:
ALTER DATABASE your_db SET search_path = 'schema_1';

You can do that per-user, too:
ALTER DATABASE username SET search_path = 'schema_1';

You can also change it in the application, by sending
SET search_path TO 'schema_1';

There are other options too, but that should suffice.

Alvaro Herrera                      
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

pgsql-interfaces by date

Next:From: Bosco RamaDate: 2008-08-20 16:39:55
Subject: Re: schema name in the SQL statement.
Previous:From: Masis, Alexander (US SSA)Date: 2008-08-19 22:47:56
Subject: Where can I get the LIBPQ++

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