pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jan Muszynski <postgres@jancm.org>
To: Michael Peters <mike101a@hotmail.com>
To: pgsql-odbc@postgresql.org
Subject: Re: Switching Between Databases
Date: Sat, 21 Jul 2007 16:55:06 -0400
Message-ID: <46A23A6A.23441.1C9A9DD@postgres.jancm.org> (raw)
In-Reply-To: <BAY115-F19E8733E464AFCA9E81C1A94F50@phx.gbl>
References: <BAY115-F19E8733E464AFCA9E81C1A94F50@phx.gbl>

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



view thread (3+ messages)

Message-ID: <46A23A6A.23441.1C9A9DD@postgres.jancm.org>
Permalink:  ../46A23A6A.23441.1C9A9DD@postgres.jancm.org/
Also on:    postgresql.org/message-id/46A23A6A.23441.1C9A9DD@postgres.jancm.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: postgres@jancm.org, mike101a@hotmail.com
  Subject: Re: Switching Between Databases
  In-Reply-To: <46A23A6A.23441.1C9A9DD@postgres.jancm.org>
  References: <BAY115-F19E8733E464AFCA9E81C1A94F50@phx.gbl> <46A23A6A.23441.1C9A9DD@postgres.jancm.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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