pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedschema name in the SQL statement.
3+ messages / 3 participants
[nested] [flat]
* schema name in the SQL statement.
@ 2008-08-19 22:43 Masis, Alexander (US SSA) <alexander.masis@baesystems.com>
0 siblings, 2 replies; 3+ messages in thread
From: Masis, Alexander \(US SSA\) @ 2008-08-19 22:43 UTC (permalink / raw)
To: pgsql-interfaces
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?
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: schema name in the SQL statement.
@ 2008-08-20 12:59 Alvaro Herrera <alvherre@commandprompt.com>
parent: Masis, Alexander (US SSA) <alexander.masis@baesystems.com>
1 sibling, 0 replies; 3+ messages in thread
From: Alvaro Herrera @ 2008-08-20 12:59 UTC (permalink / raw)
To: Masis, Alexander (US SSA) <alexander.masis@baesystems.com>; +Cc: 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 http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: schema name in the SQL statement.
@ 2008-08-20 16:39 Bosco Rama <postgres@boscorama.com>
parent: Masis, Alexander (US SSA) <alexander.masis@baesystems.com>
1 sibling, 0 replies; 3+ messages in thread
From: Bosco Rama @ 2008-08-20 16:39 UTC (permalink / raw)
To: 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.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2008-08-20 16:39 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-08-19 22:43 schema name in the SQL statement. Masis, Alexander (US SSA) <alexander.masis@baesystems.com>
2008-08-20 12:59 ` Alvaro Herrera <alvherre@commandprompt.com>
2008-08-20 16:39 ` Bosco Rama <postgres@boscorama.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox