PLSQL建立DBLINK

來源:互聯網
上載者:User

標籤:list   .com   nbsp   names   使用者建立   back   ffffff   col   res   

  Oracle建立dblink,多用於資料的同步機制。不建議直接用dblink對資料庫頻繁的操作。。。

00、查看建立dblink許可權

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

--dblink許可權

CREATE DATABASE LINK       --資料庫使用者建立dblink

DROP PUBLIC DATABASE LINK

CREATE PUBLIC DATABASE LINK

--授權dblink  sys

grant CREATE PUBLIC DATABASE LINK,DROP PUBLIC DATABASE LINK  to scott;

01、使用者登入本機資料庫建立dblink

1.建立dblink的第一種方式,是在本機資料庫tnsnames.ora檔案中配置了要遠端存取的資料庫

create public database link dblink_name connect to username identified by password using ‘bylw‘;

注釋 :

  dblink_name dblink名字

  username源庫的使用者 password    源庫的密碼

其中to_bylw是你建立的dblink名字,bylw是遠端資料庫的(名字),scott/tiger是登入到遠端資料庫的使用者/密碼

第一種情況tnsnames.ora檔案中資訊如下:bylw =(DESCRIPTION =  (ADDRESS_LIST =  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.5)(PORT = 1521)))  (CONNECT_DATA =  (SERVER = DEDICATED)  (SERVICE_NAME = bylw)))

--通過dblink查詢表資訊

select * from [email protected]_bylw;

2.建立dblink的第二種方式,是在本機資料庫tnsnames.ora檔案中沒有配置要訪問的遠端資料庫,

create public database link to_test   connect to scott identified by tigerusing ‘(DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.5)(PORT = 1521)))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = bylw)))‘;

第二種是把第一種配置在tnsnames.ora檔案中的資訊,直接放在建立dblink語句後面。

刪除dblink
drop database link "dblink_name";

--table_name 目標庫的表 dblink_name串連名字
select * from [email protected]_name;

select db_link,owner from dba_db_links;

串連到dblink的owner使用者下再次嘗試drop操作

drop database link prod;
drop public database link prod;

 02、在PLSQL便捷添加DBLINK

PLSQL建立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.