微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.

原文地址:https://www.jb51.cc/postgresql/193308.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐