1

我有 2 张桌子。表 A 付款表 B 电话

我想将以下 2 个差异模式查询的结果合并到 1 个表中。

select Payment_DT  
from DW.Payment

SELECT PHONE_NUMBER 
FROM STG_ANALYSIS.PHONE

这是我正在寻找的输出。

Payment_Dt  Phone_Number
3/31/2018   123-456-7890
4

2 回答 2

1

不知道逻辑但将两者合并应该是

select Payment_DT,
      (SELECT PHONE_NUMBER 
      FROM STG_ANALYSIS.PHONE) phone_number  
from DW.Payment

如果存在连接两个表的逻辑,则使用内/左连接

于 2018-03-21T21:42:10.880 回答
0

DB Links 几乎就是这里的游戏名称。如果您无法自己创建一个,请检查是否有任何您可以使用的公共数据库链接。

您的 DBA 也可能愿意让他们的一个 DB 链接用于在 S1 实例上创建 S2.Table2 的物化视图。

另一种选择可能是网络服务,但我猜你会遇到比使用简单数据库链接更多的管理问题。只有在没有链接的充分理由时才考虑这些(例如:两个独立的组织不想在其数据库之间打开防火墙漏洞)。

做不到这些,你就进入了非常丑陋的领域,但你也许可以做一些事情。例如:

Open up both from a tool that can read from multiple connections at once and do the join there. Access. Toad for Data Analysis, whatever.
Use a tool like Toad to copy S2.Table2 to your own schema ("create in another schema" followed by "copy data to another schema")
If you have, or can get, complementary directory objects defined on both servers, create a Materialized View of S2 as an external table in a directory which can be written from S2 and read from S1.

不过,您真的不想长期维护这些解决方案中的任何一个。

于 2018-03-22T00:22:00.400 回答