accessing two databases at the same time

Started by Peter Choeabout 23 years ago6 messagesgeneral
Jump to latest
#1Peter Choe
choepete@mindspring.com

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

#2Ian Lawrence Barwick
barwick@gmail.com
In reply to: Peter Choe (#1)
Re: accessing two databases at the same time

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

#3Tariq Muhammad
tmuhamma@libertyrms.com
In reply to: Peter Choe (#1)
Re: accessing two databases at the same time

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.

#4Darko Prenosil
darko.prenosil@finteh.hr
In reply to: Peter Choe (#1)
Re: accessing two databases at the same time

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

Show quoted text

Peter Choe

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

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

#5Medi Montaseri
medi.montaseri@intransa.com
In reply to: Tariq Muhammad (#3)
Re: accessing two databases at the same time

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:

Show quoted text

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)

#6Neil Conway
neilc@samurai.com
In reply to: Tariq Muhammad (#3)
Re: accessing two databases at the same time

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