Oracle中DBLink的使用

來源:互聯網
上載者:User

標籤:

DBLink 的作用是在區域網路內,通過一台伺服器上面的資料庫訪問另外一台伺服器上面資料庫的功能。

下面簡單的介紹DBLink的配置:

伺服器A:IP 10.10.10.107, 資料庫執行個體名:orcl 資料庫登入:test/test

伺服器B:IP 10.10.10.22,   資料庫執行個體名:kobra 資料庫登入:user/user

需求: 在A伺服器上的資料庫可以訪問伺服器B的資料庫。

select owner,object_name,object_type from dba_objects where object_type=‘DATABASE LINK‘; --查詢已經配置的DBLink串連。

SELECT * FROM GLOBAL_NAME; --查詢資料庫執行個體名。

select * from v$option; select * from v$option where PARAMETER=‘Advanced replication‘;--查詢資料庫許可權

DROP DATABASE LINK KOBRA; --刪除串連;

第一步:查詢許可權,分配許可權 

select * from user_sys_privs t where t.privilege like upper(‘%link%‘);

grant dba,conn,create database link,create public database link to test;

第二步:建立串連

create public database link kobra connect to user identified by user using ‘(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =10.10.10.22)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = kobra)
)
)‘;

注 :kobra 為訪問資料的執行個體名 user/user 為使用者名稱和密碼 特別提醒:using 後面的可以配置到tnaname.ora這個檔案中,但是會報這個錯誤:ORA-12154: TNS:could not resolve service name的解決辦法 經過網上查看 說需要直接在建立串連的時候配置進去方可。

第三步:驗證

select * from [email protected];

輸入這個之後會有傳回值,表明已經串連上了。

第四步:查詢

select * from [email protected];

能查詢到資料即證明串連成功。

 

Oracle中DBLink的使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.