我在不同的数据库D1和D2中有两个相关的表T1和T2。我需要在两个表之间进行内部联接。
从这里:Joining Results from Two Separate Databases很明显,应该对两个数据库进行单独的查询,并将结果在客户端进行合并或使用 dblink/postgres-fdw .
但是,我看到了这个问题:Multiple Databases #1
以及此处使用 $dc
参数:pg-promise/Database .
我相信问题:Multiple Databases #1 只是方便允许连接到同一代码库中的多个数据库。
$dc
参数说明:
This is mainly to facilitate the use of multiple databases which may need separate protocol extensions, or different implementations within a single task
但是,我没有找到任何示例。
$dc
参数只是一个可以访问的数据库上下文对象,还是允许在两个不同的数据库之间进行内部联接?
有没有一种方法可以利用两个数据库连接,但无需使用 pg-promise
在客户端进行跨数据库连接?
最佳答案
Is the $dc paramter just a database context object that can be accessed, or would it allow to do an inner join between two different databases?
是前者。
Is there a way to do utilise two database connections but do a join across databases in without having to do it on client-side using pg-promise?
没有。每个Database对象仅代表与数据库的单个连接。
Database Context是否允许跨多个 Database 重用任务、事务和协议(protocol)扩展对象,通过依赖它的值。
关于node.js - 是否可以使用 pg-promise 在同一查询中使用多个数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53456604/