IT貓撲網(wǎng):您身邊最放心的安全下載站! 最新更新|軟件分類|軟件專題|手機版|論壇轉(zhuǎn)貼|軟件發(fā)布

您當前所在位置: 首頁數(shù)據(jù)庫MSSQL → 在Oracle里設置訪問多個SQL Server

在Oracle里設置訪問多個SQL Server

時間:2015-06-28 00:00:00 來源:IT貓撲網(wǎng) 作者:網(wǎng)管聯(lián)盟 我要評論(0)

如何在Oracle里設置訪問多個SQL Server數(shù)據(jù)庫?假設我們要在ORACLE里同時能訪問SQL Server里默認的pubs和Northwind兩個數(shù)據(jù)庫。

1、在安裝了ORACLE9i Standard Edition或者ORACLE9i Enterprise Edition的windows機器上(IP:192.168.0.2), 產(chǎn)品要選了透明網(wǎng)關(Oracle Transparent Gateway)里訪問Microsoft SQL Server數(shù)據(jù)庫

$ORACLE9I_HOME\tg4msql\admin下新寫initpubs.ora和initnorthwind.ora配置文件.

initpubs.ora內(nèi)容如下:

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內(nèi)容如下:

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_HOME\network\admin 下listener.ora內(nèi)容如下:

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:\oracle\ora92)

  (SID_NAME = test9)

 )

  (SID_DESC=

  (SID_NAME=pubs)

  (ORACLE_HOME=d:\Oracle\Ora92) 

  (PROGRAM=tg4msql)

  )

  (SID_DESC=

  (SID_NAME=northwind)

  (ORACLE_HOME=d:\Oracle\Ora92) 

 (PROGRAM=tg4msql)

    )

  )


重啟動這臺做gateway的windows機器上(IP:192.168.0.2)TNSListener服務.

(凡是按此步驟新增可訪問的SQL Server數(shù)據(jù)庫時,TNSListener服務都要重啟動)

2、ORACLE8I,ORACLE9I的服務器端配置tnsnames.ora, 添加下面的內(nèi)容:

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


出現(xiàn)類似提示,即為成功

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毫秒)


設置數(shù)據(jù)庫參數(shù)global_names=false。

設置global_names=false不要求建立的數(shù)據(jù)庫鏈接和目的數(shù)據(jù)庫的全局名稱一致。global_names=true則要求, 多少有些不方便。

oracle9i和oracle8i都可以在DBA用戶下用SQL命令改變global_names參數(shù)

alter system set global_names=false;


建立公有的數(shù)據(jù)庫鏈接:

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下數(shù)據(jù)庫里的數(shù)據(jù):

select * from stores@pubs;

...... 	......

select * from region@northwind;

......  ......


3、使用時的注意事項

ORACLE通過訪問SQL Server的數(shù)據(jù)庫鏈接時,用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轉(zhuǎn)移到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網(wǎng)關服務器在$ORACLE9I_HOME\tg4msql\admin目錄下的initsqlserver_databaseid.ora

WINDOWS下ORACLE9i網(wǎng)關服務器listener.ora里面

<samp id="xhk6w"></samp>

相關閱讀

文章評論
發(fā)表評論

熱門文章 淺談JSP JDBC來連接SQL Server 2005的方法 淺談JSP JDBC來連接SQL Server 2005的方法 SqlServer2005對現(xiàn)有數(shù)據(jù)進行分區(qū)具體步驟 SqlServer2005對現(xiàn)有數(shù)據(jù)進行分區(qū)具體步驟 sql server系統(tǒng)表損壞的解決方法 sql server系統(tǒng)表損壞的解決方法 MS-SQL2005服務器登錄名、角色、數(shù)據(jù)庫用戶、角色、架構的關系 MS-SQL2005服務器登錄名、角色、數(shù)據(jù)庫用戶、角色、架構的關系

相關下載

    人氣排行 配置和注冊ODBC數(shù)據(jù)源-odbc數(shù)據(jù)源配置教程 如何遠程備份(還原)SQL2000數(shù)據(jù)庫 SQL2000數(shù)據(jù)庫遠程導入(導出)數(shù)據(jù) SQL2000和SQL2005數(shù)據(jù)庫服務端口查看或修改 修改Sql Server唯一約束教程 SQL Server 2005降級到2000的正確操作步驟 sql server系統(tǒng)表損壞的解決方法 淺談JSP JDBC來連接SQL Server 2005的方法

      • <big id="xhk6w"><meter id="xhk6w"></meter></big>
        <samp id="xhk6w"><del id="xhk6w"><kbd id="xhk6w"></kbd></del></samp>