Обсуждение: accessing two databases at the same time

Поиск
Список
Период
Сортировка

accessing two databases at the same time

От
Peter Choe
Дата:
if i have database 'A' with a table called 'a' and another database 'B'
with a table called 'b', is there a way to do a select using both databases
and their tables?

select * from A.a, B.b;

Peter Choe



Re: accessing two databases at the same time

От
Darko Prenosil
Дата:
On Wednesday 05 March 2003 20:17, Peter Choe wrote:
> if i have database 'A' with a table called 'a' and another database 'B'
> with a table called 'b', is there a way to do a select using both databases
> and their tables?
>
> select * from A.a, B.b;
>

See the dblink in contrib directory or
if You are familyar with postgres libpq client interface, look at
ftp://gborg.postgresql.org/pub/plpq/devel/plpq_src.tar.gz

> Peter Choe
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html



Re: accessing two databases at the same time

От
Ian Barwick
Дата:
On Wednesday 05 March 2003 21:17, Peter Choe wrote:
> if i have database 'A' with a table called 'a' and another database 'B'
> with a table called 'b', is there a way to do a select using both databases
> and their tables?
>
> select * from A.a, B.b;

Not directly, see:

http://www.postgresql.org/docs/faqs/FAQ.html#4.24

The schema functionality added in version 7.3. may well meet
your needs though, e.g. you can define schema "A" and
schema "B" and perform the same sort of query as above.

Ian Barwick
barwick@gmx.net


Re: accessing two databases at the same time

От
Tariq Muhammad
Дата:
On Wed, 5 Mar 2003, Peter Choe wrote:

> if i have database 'A' with a table called 'a' and another database 'B'
> with a table called 'b', is there a way to do a select using both databases
> and their tables?
>
> select * from A.a, B.b;
>

You may wanna have a look at dblink under contrib.

     _/_/     _/_/    _/_/  Tariq Muhammad
    _/  _/  _/   _/ _/  _/  tariq@libertyrms.info
   _/   _/ _/_/_/  _/_/_/   v:416-646-3304 x 111
  _/   _/ _/   _/ _/  _/    c:416-455-0272
 _/_/_/  _/_/_/  _/  _/     p:416-381-1457
_________________________________________________
     Liberty Registry Management Services Co.


Re: accessing two databases at the same time

От
Medi Montaseri
Дата:
It would be nice if this functionality was in the PG itself....that is
another abstraction layer
with a config file that says

db-1.schema-1.table-1 = { host-i, db-j, schema-1, table-1 }

This would be a real cluster, ie where (which host) a db runs on is
immaterial...

Tariq Muhammad wrote:

>On Wed, 5 Mar 2003, Peter Choe wrote:
>
>
>
>>if i have database 'A' with a table called 'a' and another database 'B'
>>with a table called 'b', is there a way to do a select using both databases
>>and their tables?
>>
>>select * from A.a, B.b;
>>
>>
>>
>
>You may wanna have a look at dblink under contrib.
>
>     _/_/     _/_/    _/_/  Tariq Muhammad
>    _/  _/  _/   _/ _/  _/  tariq@libertyrms.info
>   _/   _/ _/_/_/  _/_/_/   v:416-646-3304 x 111
>  _/   _/ _/   _/ _/  _/    c:416-455-0272
> _/_/_/  _/_/_/  _/  _/     p:416-381-1457
>_________________________________________________
>     Liberty Registry Management Services Co.
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 2: you can get off all lists at once with the unregister command
>    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
>




Re: accessing two databases at the same time

От
Neil Conway
Дата:
On Wed, 2003-03-05 at 16:09, Tariq Muhammad wrote:
> On Wed, 5 Mar 2003, Peter Choe wrote:
> > if i have database 'A' with a table called 'a' and another database 'B'
> > with a table called 'b', is there a way to do a select using both databases
> > and their tables?
> >
> > select * from A.a, B.b;
> >
>
> You may wanna have a look at dblink under contrib.

Or put the data into 2 different schemas -- a single query can access
relations in different schemas.

Cheers,

Neil
--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC