Thread: Database Link between 2 PostgreSQL db

Database Link between 2 PostgreSQL db

From
"Reuben D. Budiardja"
Date:
Hello,
Oracle has a concept of Database link, IE you can access data from a table in
different database, even if the database is in different host, using
something like

SELECT * FROM table@REMOTE_CONNECT;

Is there something similar in PostgreSQL? I would like to know if I can access
my data on a remote PostgreSQL server from a local PostgreSQL database.

Thank you in advance for any respond.

RDB
--
Reuben D. Budiardja
Dept. Physics and Astronomy
University of Tennesse, Knoxville, TN

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GIT/M/MU/P/S d-(++) s: a-- C++(+++) UL++++ P-- L+++>++++ E- W+++
N+ o? K- w--- !O M- V? !PS !PE Y PGP- t+ 5 X R- tv+
b++>+++ DI D(+) G e++>++++ h+(*) r++ y->++++
------END GEEK CODE BLOCK------

Re: Database Link between 2 PostgreSQL db

From
Robby Russell
Date:
On Sat, 2005-03-12 at 15:00 -0500, Reuben D. Budiardja wrote:
> Hello,
> Oracle has a concept of Database link, IE you can access data from a table in
> different database, even if the database is in different host, using
> something like
>
> SELECT * FROM table@REMOTE_CONNECT;
>
> Is there something similar in PostgreSQL? I would like to know if I can access
> my data on a remote PostgreSQL server from a local PostgreSQL database.
>
> Thank you in advance for any respond.
>
> RDB

You can use dblink.

> dblink         - Functions to return results from a remote database
>

http://www.postgresql.org/docs/current/static/queries-table-expressions.html

example:


> SELECT *
>     FROM dblink('dbname=mydb', 'select proname, prosrc from pg_proc')
>       AS t1(proname name, prosrc text)
>     WHERE proname LIKE 'bytea%';
>

Cheers,

Robby

--
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON  | www.planetargon.com
* Portland, OR  | robby@planetargon.com
* 503.351.4730  | blog.planetargon.com
* PHP-PostgreSQL Hosting & Development
* open source solutions - web hosting
****************************************/