oracle和sqlserver互訪(轉)
oracle和sqlserver互訪!
2.通過"透明閘道器"方式聯接
3.SQLSERVER訪問ORACLE
環境:windowsxp + sqlserver2000 + Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production IP:192.168.1.221
前幾天由於工作的原因查詢了oracle中查詢sqlserver資料的資料,現測試成功,整理一下貼出!
要求:從Oracle中能取SqlServer的資料
環境:
OracleDb: Linux + Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production IP:192.168.1.52(TOPPROD)
MSQLDB: Windows2000 + SqlServer2000 IP:192.168.1.50(ERPSQL),測試使用者:sa/pass 測試資料表:EK.ACPTA
閘道器: WindowsXp + Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production IP:192.168.1.221(S0504027),因為暫在測試階段,所以閘道器裝在我用的機器,閘道器可以裝在MSQLDB上
1.通過ODBC通用方式聯接
程式碼:
// A. 安裝HS部件
// 預設情況下HS部件是安裝的,查詢檢視 SYS.HS_BASE_CAPS 可得出有沒有安裝此部件!
// B. 配置ODBC
// 在"系統DNS"中配置"ODBC FOR SQLSERVER",例如:[ERPSQL]
// C. 配置TNSNAMES.ORA,路徑:ORACLE_HOMENETWORKADMIN,這一步應該在ORACLEDB(192.168.1.52)上配置! Lnk2sql = # tnsName
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.221)(PORT = 1521)) # 閘道器IP
)
(CONNECT_DATA =
(SID = hs4sql) #SID,要和監聽器裡的SID一致!
)
(HS=OK) // D. 配置listener.ora,路徑:ORACLE_HOMENETWORKADMIN LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.221)(PORT = 1521))
)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC = # 這一段為加入的
(SID_NAME = hs4sql)
(ORACLE_HOME = D:oracleora9i)
(PROGRAM = hsodbc) # 要使用的HS服務程式.
)
) // E. 重啟監聽器服務
// F. 編輯ORACLE_HOMEHSADMIN內init.ora,這裡是iniths4sql.ora,因為上面的SID=hs4sql HS_FDS_CONNECT_INFO = ERPSQL # B中設定的ODBC名稱 HS_FDS_TRACE_LEVEL = 0 // G. 建立DB LINK,以及測試 SQL> create database link ora2sql connect to "sa" identified by "pass" using 'Lnk2sql';
Database link created
SQL> select ta001,ta002 from acpta@ora2sql where rownum<5;
TA001 TA002 ----- ----------- S710 20020306001
S710 20020315001
S710 20020325001
S710 20020326001 ------------
2.通過"透明閘道器"方式聯接
程式碼:
// A. 安裝透明閘道器,在安裝時選擇自定義安裝,安裝TRANSPARENT GATEWAY FOR SQLSERVER 元件,安裝成功後會產生oracle_homeora90tg4msql目錄!
// B. 配置TNSNAMES.ORA,路徑:ORACLE_HOMENETWORKADMIN,這一步應該在ORACLEDB(192.168.1.52)上配置! TG4MSQL = # tnsName
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.221)(PORT = 1521)) # 閘道器IP
)
(CONNECT_DATA =
(SID = tg4msql ) #SID,要和監聽器裡的SID一致!
)
(HS=OK)
) // C. 配置listener.ora,路徑:ORACLE_HOMENETWORKADMIN LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.221)(PORT = 1521))
)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = tg4msql)
(SID_NAME = tg4msql)
(ORACLE_HOME = D:oracleora9i)
(PROGRAM= tg4msql)
)
) // D. 重啟監聽器服務
// E. 編輯ORACLE_HOMETG4MSQLADMIN內init.ora,這裡是inittg4msql.ora,因為上面的SID=tg4msql
#HS_FDS_CONNECT_INFO="SERVER=ERPSQL;DATABASE=EK",好多人說用這行可以,我用這行的時候出現了不能開啟連結的錯誤,改下面一行就沒問題了! HS_FDS_CONNECT_INFO=ERPSQL.EK
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER // F. 建立DB LINK,以及測試 SQL> create database link msql2 connect to "sa" identified by "pass" using 'TG4MSQL';
Database link created
SQL> select ta001,ta002 from acpta@msql2 where rownum<5;
TA001 TA002 ----- ----------- S710 20020306001
S710 20020315001
S710 20020325001
S710 20020326001 --------
程式碼:
SQL> set timing on
SQL> select ta001,ta002 from acpta@ora2sql where rownum<10;
TA001 TA002 ----- ----------- S710 20020306001
S710 20020315001
S710 20020325001
S710 20020326001
S710 20020328001
S710 20020329001
S710 20020419001
S710 20020422001
S710 20020425001
9 rows selected
Executed in 0.047 seconds
SQL> select ta001,ta002 from acpta@msql2 where rownum<10;
TA001 TA002 ----- ----------- S710 20020306001
S710 20020315001
S710 20020325001
S710 20020326001
S710 20020328001
S710 20020329001
S710 20020419001
S710 20020422001
S710 20020425001
9 rows selected
Executed in 52.281 seconds --------
3.SQLSERVER訪問ORACLE
環境:windowsxp + sqlserver2000 + Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production IP:192.168.1.221
程式碼:
// A. 新增ODBC,OdbcName=DB,OracleSid=DB
// B. 執行 sp_addlinkedserver 'LIORA', 'Oracle', 'MSDAORA', 'DB' GO
EXEC sp_addlinkedsrvlogin @rmtsrvname='LIORA',@useself='false',@locallogin='sa',@rmtuser='SYSTEM',@rmtpassword='MANAGER'
select top 10 topic,info from LIORA..SYSTEM.HELP
topic info -------------------------------------------------- --------------------------------------------------------------------------------
@ NULL @ @ ("at" sign)
@ -------------
@ NULL @ Runs the SQL*Plus statements in the specified command file. The command @ file can be called from the local file system or from a web server.
@ NULL @ @ {uri|file_name[.ext]} [arg...]
@ NULL @ where uri supports HTTP, FTP and gopher protocols in the form:
(影響 10 個資料列)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/756652/viewspace-242228/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle透明閘道器訪問SQLServer資料庫OracleSQLServer資料庫
- Oracle和sqlserver資料型別對應OracleSQLServer資料型別
- String 和Inputstreem互轉
- Oracle VirtualBox 配置宿主機與虛擬機器互訪Oracle虛擬機
- PDF 和圖片互轉
- 外網訪問本地sqlserverSQLServer
- Python3 dict和str互轉Python
- Oracle和JDE日曆轉換Oracle
- C++ string互轉wstring/Unicode互轉ANSI/Unicode互轉UTF8C++Unicode
- struct和malloc記憶體互轉例子Struct記憶體
- SpringBootDateString互轉Spring Boot
- Unicode編碼和中文互轉(JAVA實現)UnicodeJava
- 二維陣列和稀疏陣列互轉陣列
- 前端和React Native程式碼互轉總結前端React Native
- 寫一個方法把物件和字串互轉物件字串
- String和byte互轉,Base64正逆向
- sqlserver讀取oracle資料庫資料SQLServerOracle資料庫
- 10g透明閘道器訪問sqlserverSQLServer
- Oracle外網訪問Oracle
- Oracle 訪問路徑Oracle
- Struts2和Oracle資料庫互動的小DemoOracle資料庫
- 大資料視覺化安全保障之私密訪問:讓訪問和互動更安全大資料視覺化
- sqlserver建立與Oracle的連結伺服器SQLServerOracle伺服器
- 資料庫選型比對 Oracle vs sqlserver資料庫OracleSQLServer
- Holer實現外網訪問SQLServer資料庫SQLServer資料庫
- [轉載]SQLServer之檢視簡介SQLServer
- SQLServer 2012 AG強制故障轉移SQLServer
- 轉:ORACLE的JDBC連線方式:OCI和THINOracleJDBC
- Java 轉PPT為圖片、PDF、SVG、XPS、ODP以及PPT和PPTX互轉JavaSVG
- 輸入流和字串互轉InputStream2String和String2InputStream字串
- ORACLE TEXT(轉)Oracle
- ORACLE EVENTS(轉)Oracle
- Oracle Partitioning(轉)Oracle
- ORACLE DSI(轉)Oracle
- Oracle 轉MySqlOracleMySql
- Oracle 級聯表更新和SQLServer 級聯表更新OracleSQLServer
- Buffer 與 Mat 互轉
- QImage 與 Mat 互轉