scott用户创建的db_link:LINK10G
碰到以下情形:无法联系应用侧人员获取scott用户的密码来登录数据库删除scott用户创建的db_link:LINK10G。
使用sys用户无法直接删除。
可以通过以下方式删除:
创建存储过程
Create or replace procedure Drop_DbLink(schemaName varchar2, dbLink varchar2 ) is
plsql varchar2(1000);
cur number;
uid number;
rc number;
begin
select u.user_id into uid from dba_users u
where u.username = schemaName;
plsql := 'drop database link "'||dbLink||'"';
cur := SYS.DBMS_SYS_SQL.open_cursor;
SYS.DBMS_SYS_SQL.parse_as_user(
c => cur,
statement => plsql,
language_flag => DBMS_SQL.native,
userID => uid
);
rc := SYS.DBMS_SYS_SQL.execute(cur);
SYS.DBMS_SYS_SQL.close_cursor(cur);
end;
/
调用存储过程删除db_link
SQL> exec Drop_DbLink('SCOTT','LINK10G');
PL/SQL procedure successfully completed.
删除db_link后,删除存储过程。
drop procedure Drop_DbLink;