常用笔记--Oracle--dblink
?
贵州IMS实例:
企业门户用户
服务器:10.229.9.8
oracle实例:ODSAPP
用户名:ENTERPRISE_PORTAL
密码:gzdxep123
select * from odsoutput.i_out_area_info
?
测试连接:
sqlplus ENTERPRISE_PORTAL/gzdxep123@10.229.9.8:1521/ODSAPP
?
?
创建:
create public? database link? odslink connect? to ENTERPRISE_PORTAL identified by gzdxep123? using
'(DESCRIPTION =
??? (ADDRESS_LIST =
????? (ADDRESS = (PROTOCOL = TCP)(HOST = 10.229.9.8)(PORT = 1521))
??? )
??? (CONNECT_DATA =
????? (SERVICE_NAME = ODSAPP)
??? )
)'
?
删除
drop public database link ODSLINK;
?
查询:
select * from odsoutput.i_out_area_info@odslink
?
设置link用户中的表的权限为只读
create or replace view ims_vt_ods_system as
select s.system_code as SysId,
?????? s.system_name as SysName,
?????? s.system_link as SysUrl
? from ims_ot_system s
with read only
?
?
?
请注意使用 DBLINK 时,INIT.ORA中 GLOBAL_NAME 的设置:
如果为 ture , 请使用DBLINK的全称,可在 all_db_links 中查到,如果为 FALSE,不必使用全称,当出现
?
//查询全局名称
select * from global_name;
//根据全局名称来查表
select * from?? ims_ot_user@ORCL.REGRESS.RDBMS.DEV.US.ORACLE.COM