当前位置:数据库 > Oracle >>

Oracle创建、删除DATABASE LINK

Oracle创建、删除DATABASE LINK
 
创建dblink:
Sql代码  
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:
Sql代码  
DROP DATABASE LINK [name];  
--或  
DROP PUBLIC DATABASE LINK [name];  
 今天在试着删除的时候报错:
ORA-02018:database link of same name has an open connection
 
关闭dblink:
Sql代码  
ALTER SESSION CLOSE DATABASE LINK [name];  
 但是报错:
ORA-02080: database link is in use
去v$dblink查看
Sql代码  
SELECT * FROM v$dblink;  
 该dblink确实没有在transaction,很疑惑。搜一下没找到解决办法,然后把plsql关了,过一会再开,执行ALTER SESSION的时候,报错:
 ORA-02080: database link is not open
我知道这时应该可以删除了, 然后再DROP,可以了。
 
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,