Joining tables in two different databases?

From: "Michael Goldner" <MGoldner(at)agmednet(dot)com>
To: <pgsql-admin(at)postgresql(dot)org>
Subject: Joining tables in two different databases?
Date: 2007-08-09 02:22:50
Message-ID: C2DFF594.138D2%mgoldner@agmednet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Is it possible to access tables in two different databases, running on the
same server, from within psql?

I have a table in a database that is "linked" to a table in another database
(using XA transactions in Jboss). I'd like to do some archiving at the
database level, which requires that for every record in db1.table1, I need
to archive the corresponding record in db2.table1.

I seem to recall using some other rdbms in the past that allowed one to
prefix the table name with the dbname. Can this be done in postgres?

If not, it seems that I'll need to do some sort of "COPY" operation to
export the primary keys to a temporary table, import it into the second db,
and then perform my archive based on the table. Does this seem appropriate?

Otherwise, I could write the archive procedure in Java, using the XA
datasource. I was hoping to avoid the overhead and complexity involved
versus a succinct sql statement.

Thanks!

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Jessica Richard 2007-08-09 02:32:52 cpu usage on the linux machine
Previous Message Tom Lane 2007-08-09 02:16:25 Re: Specific questions about wraparound and vacuum