Oracle db link 修改host
因数据库服务器迁移,导致数据库服务器IP变化,需要修改DB LINK。
有些用户密码不清楚的情况下,使用以下方法修改DB LINLK
--源数据库IP:10.88.144.53,新数据库IP:10.5.40.211
begin
for i in (select * from dba_db_links where host like '%10.88.144.53%') loop
--修改DB LINK配置中的IP
update link$ a
set a.host = replace(a.host, '10.88.144.53', '10.5.40.211')
where a.name = i.db_link
and a.userid = i.username
and i.host = a.host;
commit;
end loop;
--刷新shared_pool
execute immediate 'alter system flush shared_pool';
end;
begin for i in (select * from dba_db_links where host like '%10.88.144.53%') loop --修改DB LINK配置中的IP update link$ a set a.host = replace(a.host, '10.88.144.53', '10.5.40.211') where a.name = i.db_link and a.userid = i.username and i.host = a.host; commit; end loop; --刷新shared_pool execute immediate 'alter system flush shared_pool';end;

浙公网安备 33010602011771号