Query two databases with Oracle SQL Developer

杀马特。学长 韩版系。学妹 提交于 2019-12-03 12:18:31

Yes, that's possible. Connections in SQL Developer won't help you - you will have to setup a database link from your Oracle database to the SQL Server database.

Before creating a database link, you'll have to setup a Heterogeneous gateway to connect to the SQL Server.

General steps include:

  • Install Oracle ODBC drivers on the server that will access the remote SQL Server database using the database link.

  • Setup the ODBC connection on the local Oracle database using the Windows ODBC Data Source Administrator

  • Test the ODBC drivers to ensure that connectivity is made to the SQL Server database.

  • Configure the Oracle Heterogeneous services by creating an initodbc.ora file within the Oracle database.

  • Modify the 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) ) )
    
  • Modify the Tnsnames.ora file to point to the gateway

        (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
        )
    
  • Reload the listener on local Oracle database

  • Create a database link on the local Oracle installation that accesses the heterogeneous connection, which, in turn, connect to SQL Server.

Once the database link is created, you should be able to insert into the database using a simple:

 insert into <oracle_tablename>
 select * from <sqlserver_table_name>@dblink_name

Further reading:

You can read data from an ODBC connection using Heterogeneous Services. It is a bit of a pain to set up though. You have to edit several files in the oracle install to setup a new TNS Listener then create a dlink within your schema/global.

This guide is for unix but is the shortest/least retarded one IMO.

The other option is to pipe data via a 3rd party program. For instance I think you can create a query in MS Access then export the data to Oracle or SQL Server.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!