[英]SQL Developer: Joining tables from connected SQL Server DB and connected Oracle DB
We are migrating from SQL Server 2005 to Oracle 11G. 我们正在从SQL Server 2005迁移到Oracle 11G。 I have been trying to do an update to a table in Oracle using data stored in a table in SQL Server. 我一直在尝试使用存储在SQL Server表中的数据对Oracle中的表进行更新。
Using SQL Developer, I have completed the following: 使用SQL Developer,我已经完成了以下工作:
Created a connection to the Oracle Database 创建到Oracle数据库的连接
Created Connection name --> e9_crp Supplied User name and Pass Defined Host Name and SID
I also created a connection to the SQL Server that contains the reference data 我还创建了到包含参考数据的SQL Server的连接
Connection Name --> sql_data User Name and Pass Host and Port
The connection name used for SQL Server is sql_data
用于SQL Server的连接名称是sql_data
The connection name used for Oracle is e9_crp
用于Oracle的连接名称为e9_crp
The table in SQL Server is in a database my_tmp
with owner of dbo and is called tiers
( my_tmp.dbo.tiers
). 在SQL Server中的表是在数据库my_tmp
拥有dbo的拥有者,被称为tiers
( my_tmp.dbo.tiers
)。
In SQL Developer, I can see, select, and view the tiers table. 在SQL Developer中,我可以查看,选择和查看层表。 This SQL statement also works using the worksheet when in the sql_data
connection: 在sql_data
连接中时,此SQL语句也可以使用工作表工作:
select * from [my_tmp].[dbo].[tiers]
Trying to connect to this table when in the e9_crp
connection schema, I have been trying to do something like this: 在e9_crp
连接模式中尝试连接到该表时,我一直在尝试执行以下操作:
select * from [sql_data].[my_tmp].[dbo].[tiers]
But this returns an error stating that the tiers table does not exist: 但这返回一个错误,指出tiers表不存在:
ORA-00903: invalid table name
00903. 00000 - "invalid table name"
Both tables have a unique ID of 'item', so in a perfect world this should work: 这两个表的ID均为“ item”,因此在理想情况下,此表应该有效:
select a.itm, b.tier
from [e9_crp].[crpdta].[itemmaster] a inner join [sql_data].[my_tmp].[dbo].[tiers] b
on(a.itm = b.itm)
This is assuming that I use the connection name in the table identifier. 假设我在表标识符中使用连接名称。 BUT, this obviously does not work. 但是,这显然行不通。 What I need to do is be able to join these 2 databases together in a similar fashion as necessary. 我需要做的是能够根据需要以类似的方式将这两个数据库连接在一起。
How can I use SQL Developer to join these 2 tables? 如何使用SQL Developer联接这两个表? I have tried multiple iterations of table strings for the join but no luck. 我为联接尝试了表字符串的多次迭代,但是没有运气。 Any help is appreciated. 任何帮助表示赞赏。
Oracle has the concept of a DBLink, and SQL Server has the concept of a Linked Server. Oracle具有DBLink的概念,而SQL Server具有Linked Server的概念。 Both these features let you query data from two separate databases. 这两个功能使您可以从两个单独的数据库中查询数据。
Here's a link with instructions for setting up an Oracle DBLink to a SQL Server DB... 这是一个链接,其中包含有关将Oracle DBLink设置为SQL Server DB的说明...
http://www.dba-oracle.com/t_database_link_sql_server_oracle.htm http://www.dba-oracle.com/t_database_link_sql_server_oracle.htm
And here's a link with instructions for setting up a SQL Server Linked Server to an Oracle DB... 这是一个链接,其中包含有关将SQL Server链接服务器设置为Oracle DB的说明。
http://support.microsoft.com/kb/280106 http://support.microsoft.com/kb/280106
See also this SO post... 另请参阅此帖子...
SQL statement joining Oracle and MS SQL Server 加入Oracle和MS SQL Server的SQL语句
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.