Oracle下dblink下的建立與使用

2022-05-29 12:09:11 字數 3091 閱讀 4867

1.跨資料庫節點建立dblink

訪問庫:

10.156.10.182

被訪問庫:

10.156.11.79(dg備庫)---10.156.11.31/32/33(dg主庫)

為了分離dg庫的壓力,訪問庫通過dblink從dg備庫取數。

1:被訪問庫建立使用者賦權:

create user query_zbx identified by 111;

grant connect to query_zbx;

grant select on elite.gd_hf_pol_add to query_zbx;

2:訪問庫上建立dblink

create public database link to_cc

connect to query_zbx identified by 111

using '(description =

(address_list =

(address = (protocol = tcp)(host = 10.156.11.79)(port = 1521))

)(connect_data =

(service_name = ccprdg)

))';

3:驗證dblink:

sql> create public database link to_cc

2 connect to query_zbx identified by 111

3 using '(description =

4 (address_list =

5 (address = (protocol = tcp)(host = 10.156.11.79)(port = 1521))

6 )

7 (connect_data =

8 (service_name = ccprdg)

9 )

10 )';

database link created.

sql> select sysdate from dual@to_cc;

sysdate

---------

06-mar-18

4:對比dg主庫,將dblink配置修改成主庫:

sql> create public database link to_cc

2 connect to query_zbx identified by 111

3 using '(description =

4 (address_list =

5 (address = (protocol = tcp)(host = 10.156.11.31)(port = 1521))

6 (address = (protocol = tcp)(host = 10.156.11.32)(port = 1521))

7 (address = (protocol = tcp)(host = 10.156.11.33)(port = 1521))

8 )

9 (connect_data =

10 (service_name = ccpr)

11 )

12 )';

database link created.

sql> select sysdate from dual@to_cc;

sysdate

---------

06-mar-18

sql> select count(*) from elite.gd_hf_pol_add@to_cc;

count(*)

----------

130124

2.不跨節點的資料的的blink建立

*****************

建立使用者test1、test2

*****************

sql> create user test1 identified by test1;

user created.

sql> create user test2 identified by test2;

user created.

*****************

使用者賦權

*****************

sql> grant connect,resource to test1;

grant succeeded.

sql> grant connect,resource to test2;

grant succeeded.

*****************

test1建立dblink

*****************

grant create public database link to test1;

create public database link test1_test2 connect to test2 identified by test2 using 'dblink';

database link created.

*****************

使用者test2測試dblink

*****************

sql> select sysdate from dual@test1_test2;

sysdate

------------------

28-nov-18

*****************

使用者test3測試dblink

*****************

sql> create user test3 identified by test3;

user created.

sql> grant connect,resource to test3;

grant succeeded.

sql> connect test3/test3

connected.

sql> select sysdate from dual@test1_test2;

sysdate

------------------

28-nov-18

ORACLE下如何建立DBLink

size large b color red 1.create database link color b size create database link b color red cimlink color b connect to b color red ccbcim color b iden...

建立Oracle的DB Link實戰

當有在一台資料庫伺服器上集合或者分類篩選位於其他資料庫伺服器上的資料時,如果從應用層面上來解決問題,可能需要占用大量記憶體並且很費事。oracle資料庫本身提供了db link的機制來達到這個目的,以下以具體步驟來實現這個操作。1.首先在管理資料庫上建立到乙個資料庫的db link.drop exi...

Oracle 建立 DBLink 的方法

1 如果需要建立全域性 dblink,則需要先確定使用者有建立 dblink 的許可權 如果沒有,則需要使用 sysdba 角色給使用者賦權 2 使用該使用者登入 pl sql,使用命令 採用圖形配置介面則如下所示 3 查詢資料 4 刪除 dblink 5 建立和刪除同義詞 6 建立和刪除檢視 7 ...