有没有办法在 Oracle SQL Developer 中查询两个数据库(在单个查询中)?
我对 Oracle 不太熟悉——无论如何,除了标准的 CRUD 语法。
我正在尝试从 SQL Server 表插入 Oracle 表。想做这样的事情:
INSERT INTO OracleDB.table (field1, 2, ...)
SELECT ... FROM SQLServerDB.schema.table
我已经在 Oracle SQL Developer 中为两个数据库创建了(工作)连接。
Thanks
--EDIT--
我对数据库本身没有管理员权限。 (无法创建链接服务器等)
是的,这是可能的。 SQL Developer 中的连接不会帮助你 - 你必须设置一个数据库链接 http://download.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_5005.htm从 Oracle 数据库到 SQL Server 数据库。
在创建数据库链接之前,您必须设置异构网关来连接到 SQL Server。
一般步骤包括:
在将使用数据库链接访问远程 SQL Server 数据库的服务器上安装 Oracle ODBC 驱动程序。
使用 Windows ODBC 数据源管理器在本地 Oracle 数据库上设置 ODBC 连接
测试 ODBC 驱动程序以确保与 SQL Server 数据库建立连接。
通过在 Oracle 数据库中创建 initodbc.ora 文件来配置 Oracle 异构服务。
-
修改Listener.ora
file.
SID_NAME is the DSN for the remote database.
ORACLE_HOME is the actual Oracle home file path.
PROGRAM tells Oracle to use heterogeneous services.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME=ora_sid) -- Enter the DSN on this line
(ORACLE_HOME = c:\oracle10gdb) -- Enter your Oracle home on this line
(PROGRAM = hsodbc) ) )
-
修改Tnsnames.ora file
指向网关
(DESCRIPTION=
(ADDRESS_LIST=
(Address=(PROTOCOL=TCP)
(HOST=
-- (Server x)
(PORT=1521))) -- Enter the port on which the server x Oracle installation
-- is listening
(CONNECT_DATA=(SID=Cas30c)) - Enter the DSN name
(HS=OK) -- Enter this value. It tells Oracle to use hetergeneous services
)
重新加载本地 Oracle 数据库上的侦听器
在本地 Oracle 安装上创建一个访问异构连接的数据库链接,该连接又连接到 SQL Server。
创建数据库链接后,您应该能够使用简单的方法插入数据库:
insert into <oracle_tablename>
select * from <sqlserver_table_name>@dblink_name
进一步阅读:
-
Oracle 文档 http://download.oracle.com/docs/cd/A87860_01/doc/server.817/a76960/hs_genco.htm#5396关于异构网关连接
-
Oracle 文档 http://download.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_5005.htm关于创建数据库链接
-
建立连接 http://www.databasejournal.com/features/oracle/article.php/3442661/Making-a-Connection-from-Oracle-to-SQL-Server.htm从 Oracle 到 SQL Server(这篇文章有点旧,但非常好,图文并茂的文章!)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)