oracle alter system kill,alter system kill session 如何实现立即结束一个会话

一般情况下,在杀掉一个会话的时候,直接执行alter system kill session ‘sid,serial#’; 随后进行查询发现,被KILL掉的会话状态变为KILLED状态,并没有立即结束,稍后再次查询该会话,确认已经结束。如果希望立即结束一个会话,如何处理?

经过查询ORACLE DOC得知

ORACLE DOC:

The KILL SESSION clause lets you mark a session as terminated, roll back ongoing transactions, release all session locks, and partially recover session resources. To use this clause, your instance must have the database open. Your session and the session to be terminated must be on the same instance unless you specify integer3.

If the session is performing some activity that must be completed, such as waiting for a reply from a remote database or rolling back a transaction, then Oracle Database waits for this activity to complete, marks the session as terminated, and then returns control to you. If the waiting lasts a minute, then Oracle Database marks the session to be terminated and returns control to you with a message that the session is marked to be terminated. The PMON background process then marks the session as terminated when the activity is complete.

IMMEDIATE Specify IMMEDIATE to instruct Oracle Database to roll back ongoing transactions, release all session locks, recover the entire session state, and return control to you immediately.

当session是active的时候,alter system kill session 只是将session标识为killed状态,并不会释放session持有的资源,所以我们在执行完alter system kill session 后,看会话还是一直存在,等待PMON进程回收资源和释放锁等。

如果:

不加IMMEDIATE,仅仅是标记该事务为中断,等待PMON进程来回收该SESSION所占用的资源及释放锁等;

加IMMEDIATE, 即在alter system kill session 'sid,serial,@sid' 后增加 immediate来实现立即结束会话。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31448585/viewspace-2151053/,如需转载,请注明出处,否则将追究法律责任。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值