问题
Is it possible to execute queries joining a MySQL DB table and an Oracle DB table?
I previously worked on MS SQL Server and I linked external DB servers inside SQL Server instance to create procedures and views integrating different DB tables.
Is something similar available on MySQL or Oracle DBMSs?
回答1:
As far as I know, DG4ODBC
allows you to connect with the MySQL ODBC
driver from an Oracle database to the MySQL database.
Since you have not mentioned the OS details, I would suggest you to check out My Oracle Support(MOS) notes for your specific OS. You can look for Oracle Database Gateway for ODBC
. Here is a link to documentation http://docs.oracle.com/cd/B28359_01/gateways.111/b31042/toc.htm.
回答2:
Yes, you can. For that you use the dg4odbc (assuming oracle >= v11) in combination with unixODBC as odbc driver manager and freeTDS as odbc driver for SQLServer.
What you do is create a listener entry in your listener.ora similar to
(SID_DESC =
(SID_NAME=yourdb)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/dbhome_1 )
(PROGRAM = dg4odbc)
(ENVS = "LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0.3/dbhome_1/lib:/usr/local/freetds/lib")
)
create a tns alias that points to this special SID - yourdb - that is going to act as the gateway to SQLServer.
your_tns_alias =
(DESCRIPTION =
(ADDRESS_LIST=
(ADDRESS =(COMMUNITY = tcp.world)(PROTOCOL = TCP)(Host = your.db.server)
(Port = 1521)
)
)
(CONNECT_DATA =
(SID = yourdb)
)
(HS=ok)
)
mind the hs=ok entry, this tells we have to do with a gateway.
In $ORACLE_HOME/hs/admin create a file named inityourdb.ora where the configuration of the gateway comes.
HS_FDS_CONNECT_INFO = yourdsn
HS_DB_NAME = yourdsn
HS_FDS_SUPPORT_STATISTICS = FALSE
HS_FDS_SHAREABLE_NAME=/usr/local/unixODBC/lib/libodbc.so
#HS_FDS_TRACE_LEVEL=debug
HS_FDS_TRACE_LEVEL=off
HS_LANGUAGE=AMERICAN_AMERICA.WE8ISO8859P15
This is the interface between the Oracle rdbms environment and ODBC. Specified are the driver manager, the DSN, here also can be some tuning parameters. The DSN is as done like regular ODBC administration. Some drivers need their own special parameters, similar like ORACLE_HOME for Oracle in order to find their own administration, like error messages .... This is the file to include those pointers.
have fun!
来源:https://stackoverflow.com/questions/26176580/how-to-link-mysql-db-to-oracle-db