Oracle 10g建立資料庫連結的方法

來源:互聯網
上載者:User
假設NA公司總部在北京,一個分公司在新疆。現在,本機電腦在分公司,資料庫SID為:SIDXJ,賬戶:userxj/xj123,IP為:192.168.1.100

總部有一個資料庫,SID為SIDBJ,帳號為:userbj/bj123,IP為192.168.1.101,

要求:在本機資料庫SIDXJ能夠訪問遠端資料庫SIDBJ。

即,在sidxj資料庫中,使用者userxj需要建立dblink,以userbj身份訪問sidbj資料庫。

步驟:

1.首先關閉兩台電腦的防火牆

獲得global_name,執行如下操作:

select * from global_name;

遠端資料庫的global_name為:sidbj.oracle.com

本地的global_name為:sidxj

查看初始化參數global_name

whow parameter global_name;

如果結果為true,則dblink名稱與遠端資料庫的global_name要一致。

查看兩個資料庫是否都支援進階複製功能

select * from v$option where parameter='Advanced replication';

如果為true,則支援。

在本機資料庫sidxj的tnsnames.ora中添加連結字串dblink_sidbj

2. 建立dblink,用於串連本機資料庫sidxj,以userxj/xj123登入

create database link sidbj.oracle.com connect to userbj identified by bj123 using 'dblink_sidbj';

其中,sidbj.oracle.com是遠端資料庫的global_name,userbj/bj123是遠端資料庫的帳號,dblink_sidbj是本地建立的連接字串,用於訪問遠端資料庫sidbj。

3.測試連接是否成功

select * from dual@sidbj.oracle.com

如果返回如下所示表示成功。

dummy

------

X

在本機資料庫中查詢dblink資訊

select owner,object_name from dba_objects where object_type='DATABASE LINK';

4. 訪問dblink

select * from test@sidbj.oracle.com;

--test是userbj方案下的一個表

聯繫我們

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