oracle创建与mysql的dblink

http://gzcj.iteye.com/blog/335685

因为偶然的原因,想通过oracle访问mysql,要使oracle访问mysql,必须配置“网关”

 

作为以后的参考,故总结了一下从oracle访问mysql的步骤:

1.先简单介绍下环境

操作系统:windows xp

oracle:9.2.1

mysql:5.0

2.下载mysql的odbc驱动,我用的是myodbc 3.5并安装

1>打开odbc

 

2>配置

3>点击test测试成功

3.配置odbc数据源,在控制面板中配置就可以了,使用系统DSN,取名为mysqltest

4.在D:\oracle\ora92\hs\admin下建立initmysqltest.ora文件

输入:

HS_FDS_CONNECT_INFO = mysqltest
HS_FDS_TRACE_LEVEL = 0

5.在D:\oracle\ora92\network\admin下修改

listener.ora

输入:

(SID_DESC =
      (SID_NAME = mysqltest)
      (ORACLE_HOME = D:\oracle\ora92)
      (PROGRAM = hsodbc)
    )

6.修改tnsnames.ora

输入:

mysqltest =
    (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = chengjin)(PORT = 1521))
            (CONNECT_DATA =
            (SID=mysqltest)
            )
           (HS =ok)
    )

7.创建dblink

create public database link mysqllink

  connect to “scott”

  identified by "tiger"
  using 'mysqltest';

 

8.访问mysql库中的表user

select "username" from "user"@mysqllink

 

插入数据

insert into "user"@mysqllink("id","username")
values('58aebde7-6611-48b3-bbe7-8cd37430b634','4be30d9814c6d4e9800e0d2ea9ec9fb00efa887b')

 

经测试均成功执行。

 

你可能感兴趣的:(oracle创建与mysql的dblink)