Oracle Database Link 的建立和使用小見

來源:互聯網
上載者:User

標籤:prot   ble   link   ddr   資料庫連接   通用   using   dba   tab   

假設:需要從資料庫db_a通過db_link串連到db_b查詢資料庫b的部分相關資訊

前提條件:

資料庫a賬戶需要有建立dblink的許可權,如果沒有可以使用dba賬戶賦許可權

grant CREATE PUBLIC DATABASE LINK to  username;
grant DROP PUBLIC DATABASE LINK to usenrame;

資料庫b帳號需要有串連的許可權,一般賬戶都有這個許可權

 

以下是建立的語句:

基本文法:

CREATE [SHARED][PUBLIC] database link link_name

      [CONNECT TO [user][current_user] IDENTIFIED BY password]
      [AUTHENTICATED BY user IDENTIFIED BY password]
      [USING ‘connect_string‘]

 

執行個體:

create database link a_to_b

connect to user_b_username identified by user_b_password

using ‘資料庫b地址:連接埠/服務名‘

這個比較簡單的一種方式

其中:

a_to_b是串連名

user_b_username 是要接連的目標的資料庫使用者

user_b_password是要串連的目標資料庫密碼

 

資料庫叢集的話也可以這麼寫

create public database link dblinkname connect to username identified by password
   using ‘(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = database_ip)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME =servicename)
)
)‘;

 

訪問相關資訊

select * from [email protected]a_to_b

查詢資料庫連接:

select * from dba_db_links

刪除串連:

drop database link a_to_b

 

另外 此種方式預設建立的是本使用者可用,如果要通用的可以建立public database link

 

Oracle Database Link 的建立和使用小見

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.