Oracle 提供資料庫連結功能,實現從當前資料庫連結到其他資料庫,從當前資料庫操作其他資料庫上的數據。
創建連結
CREATE DATABASE LINK dblinkname CONNECT TO dbuser IDENTIFIED BY your_password USING 'orcl'; CREATE PUBLIC DATABASE LINK 數據鏈名稱 CONNECT TO 登陸用戶名 IDENTIFIED BY 密碼 USING '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 對方Oracle伺服器的IP地址)(PORT = 連接埠號)) ) (CONNECT_DATA =(SERVICE_NAME = 對方Oracle伺服器服務名) ))'
查詢
select * from v$dblink; select * from user_db_links; select owner, db_link from dba_db_links;
刪除連結
drop database link 數據鏈名稱;
例 81.1. DB LINK
CREATE DATABASE LINK WEB CONNECT TO WEB IDENTIFIED BY 0CfJly7y5YB060Cf5YBCf USING 'orcl'; CREATE VIEW ACCOUNT AS SELECT username, password FROM member@WEB; select * from ACCOUNT where username="netkiller";