postgresql – 从两个独立的数据库加入结果

是否可以从两个单独的postgres数据库中加入行?

我在一个服务器与夫妇数据库的系统工作,有时我真的需要这样的功能

根据 http://wiki.postgresql.org/wiki/FAQ

There is no way to query a database other than the current one.
Because Postgresql loads database-specific system catalogs,it is
uncertain how a cross-database query should even behave.
contrib/dblink allows cross-database queries using function calls. Of
course,a client can also make simultaneous connections to different
databases and merge the results on the client side.

编辑:3年后(2014年3月),此常见问题条目已修订,更有帮助:

How do I perform queries using multiple databases?

There is no way to directly query a database other than the current
one. Because Postgresql loads database-specific system catalogs,it is
uncertain how a cross-database query should even behave.

The sql/MED support in Postgresql allows a “foreign data wrapper” to
be created,linking tables in a remote database to the local database.
The remote database might be another database on the same Postgresql
instance,or a database half way around the world,it doesn’t matter.
postgres_fdw is built-in to Postgresql 9.3 and includes read/write
support; a read-only version for 9.2 can be compiled and installed as
a contrib module.

contrib/dblink allows cross-database queries using function calls and
is available for much older Postgresql versions. Unlike postgres_fdw
it can’t “push down” conditions to the Remote Server,so it’ll often
land up fetching a lot more data than you need.

Of course,a client can also make simultaneous connections to different databases and merge the results on the client side.

相关文章

项目需要,有个数据需要导入,拿到手一开始以为是mysql,结果...
本文小编为大家详细介绍“怎么查看PostgreSQL数据库中所有表...
错误现象问题原因这是在远程连接时pg_hba.conf文件没有配置正...
因本地资源有限,在公共测试环境搭建了PGsql环境,从数据库本...
wamp 环境 这个提示就是说你的版本低于10了。 先打印ph...
psycopg2.OperationalError: SSL SYSCALL error: EOF detect...