• 在Oracle里设置造访多个SQL Server


     前导发轫:网海拾贝




    若安在Oracle里设置造访多个SQL Server数据库?假定我们要在ORACLE里同时能造访SQL Server里默许的pubs和Northwind两个数据库。

    1、在装配了ORACLE9i Standard Edition大概ORACLE9i Enterprise Edition的windows呆板上(IP:192.168.0.2), 产品要选了透明网关(Oracle Transparent Gateway)里造访Microsoft SQL Server数据库

    $ORACLE9I_HOMEtg4msqladmin下新写initpubs.ora和initnorthwind.ora装备文件.
    initpubs.ora内容如下:
    HS_FDS_CONNECT_INFO="SERVER=SQLSERVER_HOSTNMAE;DATABASE=pubs"
    HS_DB_NAME=pubs
    HS_FDS_TRACE_LEVEL=OFF
    HS_FDS_RECOVERY_ACCOUNT=RECOVER
    HS_FDS_RECOVERY_PWD=RECOVER
    initnorthwind.ora内容如下:
    HS_FDS_CONNECT_INFO="SERVER=sqlserver_hostname;DATABASE=Northwind"
    HS_DB_NAME=Northwind
    HS_FDS_TRACE_LEVEL=OFF
    HS_FDS_RECOVERY_ACCOUNT=RECOVER
    HS_FDS_RECOVERY_PWD=RECOVER
    $ORACLE9I_HOMEnetworkadmin 下listener.ora内容如下:
    LISTENER =
      (DEscriptION_LIST =
       (DEscriptION =
        (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.2)(PORT = 1521))
      )
      )
      )
    SID_LIST_LISTENER =
      (SID_LIST =
      (SID_DESC =
      (GLOBAL_DBNAME = test9)
      (ORACLE_HOME = d:oracleora92)
      (SID_NAME = test9)
     )
      (SID_DESC=
      (SID_NAME=pubs)
      (ORACLE_HOME=d:OracleOra92) 
      (PROGRAM=tg4msql)
      )
      (SID_DESC=
      (SID_NAME=northwind)
      (ORACLE_HOME=d:OracleOra92) 
     (PROGRAM=tg4msql)
        )
      )



    重启动这台做gateway的windows呆板上(IP:192.168.0.2)TNSListener效劳.

    (平日按此步骤新增可造访的SQL Server数据库时,TNSListener效劳都要重启动)

    2、ORACLE8I,ORACLE9I的效劳器端装备tnsnames.ora, 添加上面的内容:

    pubs =
      (DEscriptION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.2)(PORT = 1521))
        )
        (CONNECT_DATA =
        (SID = pubs)
        )
        (HS = pubs) 
       )
    northwind =
      (DEscriptION =
      (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.2)(PORT = 1521))
        )
        (CONNECT_DATA =
        (SID = northwind)
        )
        (HS = northwind) 
       )   
     保管tnsnames.ora后,在敕令行下
     tnsping pubs
     tnsping northwind



    泛起相似提示,即为告成

    Attempting to contact (DEscriptION = (ADDRESS_LIST = 
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.2)
    (PORT = 1521))) (CONNECT_DATA = (SID = pubs)) (HS = pubs))
    OK(20毫秒)
    Attempting to contact (DEscriptION = (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.2)
    (PORT = 1521))) (CONNECT_DATA = (SID = northwind)) (HS = northwind))
    OK(20毫秒)



    设置数据库参数global_names=false。

    设置global_names=false不要求挺立的数据库链接和方针数据库的全局称呼不合。global_names=true则要求, 几多有些倒运便。

    oracle9i和oracle8i都可以在DBA用户下用SQL敕令窜改global_names参数

    alter system set global_names=false;



    挺立公有的数据库链接:

    create public database link pubs 
    connect to testuser identified by testuser_pwd using 'pubs';
    create public database link northwind 
    connect to testuser identified by testuser_pwd using 'northwind';
    (假定SQL Server下pubs和northwind已有充足权限的用户上岸testuser,
    密码为testuser_pwd)



    造访SQL Server下数据库里的数据:

    select * from stores@pubs;
    ...... 	......
    select * from region@northwind;
    ......  ......



    3、运用时的留意事件

    ORACLE经由议定造访SQL Server的数据库链接时,用select * 的时辰字段名是用双引号惹起来的。

    例如:

    create table stores as select * from stores@pubs;
    select zip from stores;
    ERROR 位于第 1 行:
    ORA-00904: 无效列名
    select "zip" from stores;
    zip
    -----
    98056
    92789
    96745
    98014
    90019
    89076



    已选择6行。

    用SQL Navigator或Toad看从SQL Server转移到ORACLE里的表的建表语句为:

    CREATE TABLE stores
        ("stor_id"                      CHAR(4) NOT NULL,
        "stor_name"                    VARCHAR2(40),
        "stor_address"                 VARCHAR2(40),
        "city"                         VARCHAR2(20),
        "state"                        CHAR(2),
        "zip"                          CHAR(5))
      PCTFREE     10
      PCTUSED     40
      INITRANS    1
      MAXTRANS    255
      TABLESPACE  users
      STORAGE   (
        INITIAL     131072
        NEXT        131072
        PCTINCREASE 0
        MINEXTENTS  1
        MAXEXTENTS  2147483645
      )
    /



    总结:

    WINDOWS下ORACLE9i网关效劳器在$ORACLE9I_HOMEtg4msqladmin目次下的initsqlserver_databaseid.ora

    WINDOWS下ORACLE9i网关效劳器listener.ora内中

    (SID_DESC=
         		(SID_NAME=sqlserver_databaseid)
          		(ORACLE_HOME=d:OracleOra92) 
          		(PROGRAM=tg4msql)
       	)
       	UNIX或WINDOWS下ORACLE8I,ORACLE9I效劳器tnsnames.ora内中
    	northwind =
    	  (DEscriptION =
    (ADDRESS_LIST =
    	(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.2)(PORT = 1521))
    	    )
    	(CONNECT_DATA =
    	(SID = sqlserver_databaseid)
        		)
    	(HS = sqlserver_databaseid) 
       	   )



    sqlserver_databaseid不合才行.




    版权声明: 原创作品,承诺转载,转载时请务必以超链接方式标明文章 原始缘故原由 、作者信息和本声明。不然将清查法则责任。

  • 相关阅读:
    Android Studio3.1.2编译时Java Compiler出错:Warning: Failed to parse host proxy3.bj...
    Android RxJava 2 的用法 just 、from、map、subscribe、flatmap、Flowable、Function、Consumer ...【转】
    Android DevArt6:Android中IPC的六种方式
    Android 深入浅出
    Eclipse代码自动补全
    Android 深入浅出
    Android 深入浅出
    Android中查看SQLite中字段数据的两种方式
    Android Studio 打包时 Signature Version 选择V1还是V2 ?
    Android进阶AIDL
  • 原文地址:https://www.cnblogs.com/zgqjymx/p/1975871.html
Copyright © 2020-2023  润新知