With PostgreSQL 9.1 or later, installation of additional modules has been simplified. Registered extensions (including dblink) can be installed with CREATE EXTENSION
:
CREATE EXTENSION dblink;
Run once per database. Or run it in the standard system database template1
to add it to every newly created DB automatically. Details in the manual.
Ejemplo:
select t.*
from dblink('host=localhost dbname=bd user=postgres password=secret',
'select id, name from table')
as t(id int, name varchar)
where id < 100
order by id desc
Mas ejemplos:
http://www.postgresonline.com/journal/archives/44-Using-DbLink-to-access-other-PostgreSQL-Databases-and-Servers.html