Oracle中dblink所产生远程会话的一些表现

作者: Maclean Liu , post on September 9th, 2009 , English Version
【本站文章除注明转载外,均为本站原创编译】
转载请注明:文章转载自: Oracle Clinic – Maclean Liu的个人技术博客 [http://www.oracledatabase12g.com/]
本文标题: Oracle中dblink所产生远程会话的一些表现
本文永久地址: http://www.oracledatabase12g.com/archives/oracle%e4%b8%addblink%e6%89%80%e4%ba%a7%e7%94%9f%e8%bf%9c%e7%a8%8b%e4%bc%9a%e8%af%9d%e7%9a%84%e4%b8%80%e4%ba%9b%e8%a1%a8%e7%8e%b0.html

惯性思维总是 令我们离大师们 有着一定的距离,这种差距 在知识广袤的领域尤其明显。

Oracle领域被称为Oracle的世界,当之无愧;一丁点的想当然就让我们偏离于事实。

以dblink的表现为例,我一直认为dblink的远程连接session仅在操作(select,dml)发生时短期存在,在操作完成后依据一定条件保留或退出。

而事实并非如此,随便使用一个远程查询语句如下:

SQL> select * from help@LZ;       –LZ 为dblink名

在远程数据库端观察session,可以发现:

select sid,username,machine,program,module from v$session where module=’ORACLE.EXE’

SID USERNAME MACHINE PROGRAM MODULE
1 526 SYSTEM WIN_DESK1 ORACLE.EXE ORACLE.EXE

且该远程会话一直保留直到原会话退出为止,无论是成功退出还是程序失败。

若希望在原会话中关掉已打开的远程会话,则需要使用一下命令:
Alter session close database link DBLINKNAME;

这里要注意,需要先执行commit后以上关闭远程session SQL方会成功,即便是Select操作也是如此;

若没有执行commit,会出现:

ORA-02080: 数据库链接正在使用中

© 2009, www.oracledatabase12g.com. 版权所有.文章允许转载,但必须以链接方式注明源地址,否则追究法律责任.

相关文章 | Related posts:

  1. 脚本:监控数据库中的活跃用户及其运行的SQL
  2. Script:List SORT ACTIVITY
  3. 使用ALTER SYSTEM运行OS命令

1 comment to Oracle中dblink所产生远程会话的一些表现

  • admin

    How To Remove a Dead Connection to the Target Database Through DBlink After a Network Connection Failure
    Applies to:
    Oracle Net Services – Version: 8.1.7 to 9.2
    Information in this document applies to any platform.
    Goal
    This document describe how you can remove a dead connection to the remote database through dblink after a network connection failure with the remote database server.
    Solution

    1. Please set (ENABLE=BROKEN) in the connect string for the target database in the tnsnames.ora file at the origin or source database ORACLE_HOME\network\admin or TNS_ADMIN directory.

    E.g.
    TEST.WORLD =
    (DESCRIPTION =
    (ENABLE=BROKEN)
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = < >)(PORT = < >))
    )
    (CONNECT_DATA =
    (SERVICE_NAME = DISCARD.WORLD)
    ) )
    2. Please create the dblink using this connect string.
    3. Please set the OS tcp/ip keepalive parameter in the local databse to a desired low value (e.g. 5 minutes).

    Please note that in the case of a database link, the target destination of the link constitutes the server side of the connection. So it is not possible to use the DCD to close the database link from the origin database server in case of a network failure.

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>