WEB开发网
开发学院数据库Oracle Oracle10g中通过DBLink访问MySQL数据 阅读

Oracle10g中通过DBLink访问MySQL数据

 2009-02-12 13:08:57 来源:WEB开发网   
核心提示: 以上工作完成后,执行lsnrctl reload命令使新配置生效:su – oraclelsnrctl reloadLSNRCTL for Linux: Version 10.2.0.4.0 - Production on 09-FEB-2009 13:59:38 Copyri

以上工作完成后,执行lsnrctl reload命令使新配置生效:su – oracle
lsnrctl reload
LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 09-FEB-2009 13:59:38 Copyright (c) 1991, 2007, Oracle.
All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
The command completed successfully
lsnrctl status
LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 12-FEB-2009 08:56:00
  
Copyright (c) 1991, 2007, Oracle. All rights reserved.
  
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias           LISTENER
Version          TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date        03-JAN-2009 03:47:39
Uptime          40 days 5 hr. 8 min. 20 sec
Trace Level        off
Security         ON: Local OS Authentication
SNMP           OFF
Listener Parameter File  /ora10g/network/admin/listener.ora
Listener Log File     /ora10g/network/log/listener.log
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
 Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "test" has 1 instance(s).
 Instance "test", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

6, 编辑Oracle Database所在计算机中的tnsnames.ora文件,便于建立dblink,注意,此tnsnames的配置可以支持tnsping,但是不能支持sqlplus登录,只用于dblink:

vi /ora10g/network/admin/tnsnames.ora
mypts =
 (DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
  (CONNECT_DATA =
   (SID = test)
  )
   (HS = OK)
 )

7, 在Oracle Database建立dblink:

create public database link MYSQL
connect to "mysql username" identified by "mysql pwd"
using '(DESCRIPTION =
       (ADDRESS = (PROTOCOL = TCP) (HOST = 127.0.0.1) (PORT =1521) )
       (CONNECT_DATA = (SID= test) )
       (HS=OK)
      )';

要注意用户名和密码处需要用双引号扩起来,否则Oracle所传输的都是大写字母,可能无法登录进入MySQL。

8, 由于MySQL中的表名的大小写敏感,因此需要在进行SQL查询时对表名用双引号扩起来,或者在建立MySQL库时就将所有表名都设为大写的也可以 select * from

上一页  1 2 3 

Tags:Oracleg 通过 DBLink

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接