ORACLE中alter system kill session怎么实现立即结束一个会话

发布时间:2021-11-09 09:45:46 作者:小新
来源:亿速云 阅读:1762

这篇文章主要为大家展示了“ORACLE中alter system kill session怎么实现立即结束一个会话”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“ORACLE中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来实现立即结束会话。

以上是“ORACLE中alter system kill session怎么实现立即结束一个会话”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

推荐阅读:
  1. oracle快速彻底杀掉session
  2. ORACLE系列脚本3:救命的JOB处理脚本

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

oracle

上一篇:linux系统常见问题的解决方案有哪些

下一篇:docker里的容器怎么更新

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》