通过在ALTER SYSTEM DISCONNECT SESSION 后增加 POST_TRANSACTION来实现事务提交或回滚后,会话才会被KILL掉。
node2:
SQL> conn sh/sh
Connected.
SQL> select sid ,serial# from v$session where sid=userenv('sid');
SID SERIAL#
---------- ----------
142 63
SQL> insert into test select a.* from all_objects a ,all_objects b;
node1:
SQL> alter system disconnect session '142,63,@2' post_transaction;
System altered.
node2:
SQL> insert into test select a.* from all_objects a ,all_objects b;
^Cinsert into test select a.* from all_objects a ,all_objects b
*
ERROR at line 1:
ORA-01013: user requested cancel of current operation
SQL> rollback;
rollback
*
ERROR at line 1:
ORA-00028: your session has been killed
ORACLE DOC:
The POST_TRANSACTION setting allows ongoing transactions to complete before the session is disconnected. If the session has no ongoing transactions, then this clause has the same effect described for as KILL SESSION.
node2:
SQL> conn sh/sh
Connected.
SQL> select sid ,serial# from v$session where sid=userenv('sid');
SID SERIAL#
---------- ----------
142 63
SQL> insert into test select a.* from all_objects a ,all_objects b;
node1:
SQL> alter system disconnect session '142,63,@2' post_transaction;
System altered.
node2:
SQL> insert into test select a.* from all_objects a ,all_objects b;
^Cinsert into test select a.* from all_objects a ,all_objects b
*
ERROR at line 1:
ORA-01013: user requested cancel of current operation
SQL> rollback;
rollback
*
ERROR at line 1:
ORA-00028: your session has been killed
ORACLE DOC:
The POST_TRANSACTION setting allows ongoing transactions to complete before the session is disconnected. If the session has no ongoing transactions, then this clause has the same effect described for as KILL SESSION.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31448585/viewspace-2151052/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/31448585/viewspace-2151052/
本文介绍如何利用ALTER SYSTEM DISCONNECT SESSION命令结合POST_TRANSACTION参数,在Oracle中实现在事务提交或回滚之后才断开会话的功能。这种方法允许正在进行的事务完成,避免了因会话被直接终止而导致的数据不一致问题。
803

被折叠的 条评论
为什么被折叠?



