As we know, the private db_links can be dropped only by the owner of the database_link. But you don’t have the password that db_link owner, then there is a workaround for that.
SQL>select * from dba_db_links where OWNER='SCOTT'; OWNER DB_LINK USERNAME HOST CREATED ------------------------------ -------------------- ------------------------------ -------------------- --------- SCOTT LINK1 SCOTT testdb 04-NOV-11
SQL>drop database link scott.LINK1; drop database link scott.LINK1 * ERROR at line 1: ORA-02024: database link not found
Now create one procedure under scoot user:
SQL> CREATE PROCEDURE scott.drop_db_link AS BEGIN EXECUTE IMMEDIATE 'drop database link LINK1'; END drop_db_link; 2 3 4 5 / Procedure created
SQL> exec scott.drop_db_link PL/SQL procedure successfully completed.
SQL> select * from dba_db_links where OWNER='SCOTT'; no rows selected
Fantastic !!!!!