一.查看dblink
1)查看全部用户 SELECT OWNER,OBJECT_NAME FROM DBA_OBJECTS WHERE OBJECT_TYPE='DATABASE LINK';
2)查看全部用户 SELECT * FROM DBA_DB_LINKS;
查看本用户 SELECT * FROM USER_DB_LINKS;
二.创建dblink
2.1如果没有权限的话给权限(有权限的话省略)
给scoot用户权限
GRANT CREATE PUBLIC DATABASE LINK,CREATE DATABASE LINK TO SCOOT;
2.2 创建dblink
-- (CONNECTION为DBLINK名字,SCOTT为数据库用户名,TIGER为用户名密码,引号内容为远程数据库下TNSNAMES.ORA文件内容) CREATE DATABASE LINK CONNECTION CONNECT TO SCOTT IDENTIFIED BY "TIGER" USING '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.52)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORCL) ) )'
3.使用dblink
SELECT * FROM DEPT@connection;
三.删除dblink
drop database link connection;
四. 注意
dblink不能进行DDL(create、truncate、drop、alter)操作!