oracle dblink创建

oracle 11G R2

实例1:  192.168.1.211           实例名:feng

实例2:  192.168.1.212           实例名:wan


现在要在实例2,上面做dblink,查询实例1上面的数据


实例1的oracle管理员用户system及密码oracle


在实例2上面修改

vim /data/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora

增加

REFENG =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.211)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = feng)
    )
  )


然后sqlplus / as sysdba,创建dblink

create public database link feng CONNECT TO system IDENTIFIED BY "oracle" USING 'REFENG';

注意:以上的密码一定要用双引号,引起来否则可能出现用户名密码是对的,但是出现用户名密码错误



删除dblink
drop public database link feng;


查看已创建的dblink
select owner,object_name from dba_objects where object_type='DATABASE LINK';




查询数据


select * from 用户.表@dblink名







你可能感兴趣的:(oracle,DBlink)