Cross-database tables

From: Ron Johnson <rjohnson(at)rjohnson(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Cross-database tables
Date: 2001-01-07 01:56:31
Message-ID: befe3ba109850821c46b1877da1ca82c.1yyiUmKVrL9Sn@rjohnson.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,

I'd love it if I could access tables from other databases.

Is there a way to do this?

Here's some sample pseudo-SQL in case I wasn't clear about that:

select * from database1^table3, database2^table4;

Which would do something similar to:

psql -d database1 -c 'select * from table3;'
psql -d database2 -c 'select * from table4;'

All I see when I've read docs, or checked other sources is that databases
are separate, and can't access other info.

I suppose that answers my question -- but it just doesn't seem right.
It'd seem like there oughtta be a way, somehow, to access (at least read!)
data from multiple tables in multiple databases -- at least on the same
site.

There are only two other ways I can think of to do this...

1) Consolidate all tables into a single database. I'd have a lot of
stuff in that database then. Uck.

2) Write scripts that access both databases, and essentially duplicate
some of the database functions in the script.

So far, I do small parts of method 2, and in some cases, simply copy info
from one database to another, duplicating it.

Any other ideas are welcome.

--
RJohnson.com -+- Ron Johnson <rjohnson(at)rjohnson(dot)com>
http://www2.rjohnson.com/me/1yyiUmKVrL9Sn/

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Brett W. McCoy 2001-01-07 02:25:13 Re: Cross-database tables
Previous Message Tom Lane 2001-01-07 01:27:30 Re: Join question