日期:2014-05-16  浏览次数:20680 次

Oracle创建、删除DATABASE LINK

创建dblink:

create database link [name]
  connect to [username] IDENTIFIED BY [password]
  using '(DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = [ip])(PORT = [port]))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = xxx)
    )
  )';

?

删除dblink:

DROP DATABASE LINK [name];
--或
DROP PUBLIC DATABASE LINK [name];

?今天在试着删除的时候报错:

ORA-02018:database link of same name has an open connection

?

关闭dblink:

ALTER SESSION CLOSE DATABASE LINK [name];

?但是报错:

ORA-02080: database link is in use

去v$dblink查看

SELECT * FROM v$dblink;

?该dblink确实没有在transaction,很疑惑。搜一下没找到解决办法,然后把plsql关了,过一会再开,执行ALTER SESSION的时候,报错:

?ORA-02080: database link is not open

我知道这时应该可以删除了,?然后再DROP,可以了。

?

?

?

?

?