在oracle中,通过dblink去访问其他数据库时,会建立一个session。访问完毕后,此session并不会主动释放,需要自己手动去关闭那个session。
please close dblink by following command:
1.
SQL> commit;
SQL> alter session close database link <name>;
or Use the following package:
2.
SQL> commit;
SQL> begin
dbms_session.close_database_link('<name>');
end;
/
=== ODM Test Case ===
local db:r1020_1, remote db:r1020_4
create dblink 'james_4' from r1020_1 to r1020_4
In client,connect to r1020_1 and then access r1020_4 with dblink:
$ sqlplus james/oracle@r1020_1
--access r1020_4 with dblink
SQL> select * from dept@james_4;
DEPTNO DNAME LOC
---------- ---------------------------- --------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
--close dblink method 1 :
SQL> commit;
SQL> ALTER SESSION CLOSE DATABASE LINK james_4;
in plsql used:
execute immediate ' ALTER SESSION CLOSE DATABASE LINK james_4';
or
--close dblink method 2 :
SQL> commit;
SQL> begin
dbms_session.close_database_link('james_4');
end;
/
In r1020_4,this dblink session has been disappear.