起因:订单表原来在90库上,后各种原因移到了40库上,需访问40库上的订单表。采用DBLINK+同义词方法:
-- 1 在90机器上用GPSV4登录PLSQL,创建DBLINK,从本地数据库,连接到远程40的机器。
192.168.20.40是在F:appAdministratorproduct11.2.0dbhome_1NETWORKADMIN nsnames.ora中配置的,连接到40机器:
create public database link link40
connect to gpsv4 identified by TruePassword
using '192.168.20.40';
--2 测试连接
select * from dual@link40;
select owner,object_name from dba_objects where object_type='DATABASE LINK';
-- 3 用gpsv4_hzyg登录
create or replace synonym t_t_disp_orders for gpsv4.t_disp_orders@link40;
select * from gpsv4.t_disp_orders@link40; select * from t_t_disp_orders;