建立一個連結到其他資料庫的DBLINK

xypincle發表於2017-02-20

  1. --建立一個連結到其他資料庫的連結
  2. --USING 'BitOrcl' 中的 BitOrcl 為 tnsnames.ora 中配置

  3. CREATE SHARED PUBLIC DATABASE LINK BitOrcl
  4. AUTHENTICATED BY SYS IDENTIFIED BY his
  5. USING 'BitOrcl' ;

  6. --使用方法,在表格後面加上需要連結資料庫的DBLink名:

  7. SELECT * FROM 人員表@BitOral ;

  8. --刪除DBLink
  9. DROP PUBLIC DATABASE LINK BitOral ;

  10. --建立一個連線到電子病歷伺服器的連結
  11. CREATE SHARED PUBLIC DATABASE LINK EmrOrcl
  12. AUTHENTICATED BY SYS IDENTIFIED BY his
  13. USING '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.71.103)(PORT = 1521))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = emrorcl)))' ;

  14. --刪除DBLink
  15. DROP PUBLIC DATABASE LINK EmrOrcl ;

  16. --建立一個連線到測試伺服器的連結
  17. CREATE PUBLIC DATABASE LINK BitTest
  18. CONNECT TO SYS IDENTIFIED BY his
  19. USING '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.71.115)(PORT = 1521))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = orcl)))' ;

  20. CREATE PUBLIC DATABASE LINK Hisinterface
  21. CONNECT TO ZLHIS IDENTIFIED BY HIS
  22. USING '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.168.110)(PORT = 1521))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = orcl)))' ;

  23. --刪除DBLink
  24. DROP PUBLIC DATABASE LINK BitTest ;

 --建立一個簡易的dblink
 create public database link HisInterface connect to zlhis identified by his using '192.168.168.110:1521/orcl';


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28878983/viewspace-2133926/,如需轉載,請註明出處,否則將追究法律責任。

相關文章