pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feedSwitching Between Databases
3+ messages / 3 participants
[nested] [flat]
* Switching Between Databases
@ 2007-07-21 06:25 Michael Peters <mike101a@hotmail.com>
0 siblings, 2 replies; 3+ messages in thread
From: Michael Peters @ 2007-07-21 06:25 UTC (permalink / raw)
To: pgsql-odbc
I was not entirely sure how to frame my search of ODBC mailing database on
this topic so my apologies if it has been previously discussed at length.
When using the MySQL ODBC driver it is possible to frame an SQL query to
select a chosen database on the fly.within a single DSN Connection Instance
For example
Select * from weather.cities
Would select everything from the Cities Table within the Weather DB.
Alternatively
Use Weather
Select * from cities
Would do the same thing but require two SQL statements similar to psql which
would be
\c weather
Select * from cities
Question
Is it possible when using the PostgreSQL ODBC driver to switch back and
forth between different Databases within a single connection instance?
Mike
_________________________________________________________________
Advertisement: Make shopping exciting. Find what you want at www.eBay.com.au
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Frover%2Eebay%2Ecom%2Frover%2F1%2F705%2D10129%2D5668%...
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Switching Between Databases
@ 2007-07-21 16:15 Tom Lane <tgl@sss.pgh.pa.us>
parent: Michael Peters <mike101a@hotmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: Tom Lane @ 2007-07-21 16:15 UTC (permalink / raw)
To: Michael Peters <mike101a@hotmail.com>; +Cc: pgsql-odbc
"Michael Peters" <mike101a@hotmail.com> writes:
> Is it possible when using the PostgreSQL ODBC driver to switch back and
> forth between different Databases within a single connection instance?
No, but if you're looking for a MySQL substitute, our schemas act a
lot more like their databases than our databases do.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Switching Between Databases
@ 2007-07-21 20:55 Jan Muszynski <postgres@jancm.org>
parent: Michael Peters <mike101a@hotmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: Jan Muszynski @ 2007-07-21 20:55 UTC (permalink / raw)
To: Michael Peters <mike101a@hotmail.com>; pgsql-odbc
On 21 Jul 2007 at 16:25, Michael Peters wrote:
> I was not entirely sure how to frame my search of ODBC mailing database on
> this topic so my apologies if it has been previously discussed at length.
>
> When using the MySQL ODBC driver it is possible to frame an SQL query to
> select a chosen database on the fly.within a single DSN Connection Instance
>
> For example
>
> Select * from weather.cities
>
> Would select everything from the Cities Table within the Weather DB.
>
> Alternatively
>
> Use Weather
> Select * from cities
>
> Would do the same thing but require two SQL statements similar to psql which
> would be
>
> \c weather
> Select * from cities
>
> Question
>
> Is it possible when using the PostgreSQL ODBC driver to switch back and
> forth between different Databases within a single connection instance?
>
> Mike
You can switch between schemas, but not between DB's. Which means that you
can accomplish the same thing, just approaching it differently.
Instead of multiple DB's just set up multiple schema's. Then the way to
chenage becomes:
Select item from schema1.table;
or
SET search_path TO schema1;
Select item from table;
That will select from schema1.table
You can also say something like:
SET search_path TO schema1,schema2,public;
and in that case any object will be chosen from the first schema (in the
defined sequence) in which it's found (with public being the default
schema).
Read up on schemas in the documentation for more info. But, at least at
the current time, a construct like dbname.schema.table isn't supported
(which is what would be needed for multiple DB support).
HTH
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2007-07-21 20:55 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-07-21 06:25 Switching Between Databases Michael Peters <mike101a@hotmail.com>
2007-07-21 16:15 ` Tom Lane <tgl@sss.pgh.pa.us>
2007-07-21 20:55 ` Jan Muszynski <postgres@jancm.org>
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