ORACLE中altersystemkillsession怎么实现立即结束一个会话
这篇文章主要为大家展示了“ORACLE中alter system kill session怎么实现立即结束一个会话”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“ORACLE中alter system kill session怎么实现立即结束一个会话”这篇文章吧。
成都创新互联是一家成都网站设计、成都网站制作,提供网页设计,网站设计,网站制作,建网站,按需网站开发,网站开发公司,公司2013年成立是互联行业建设者,服务者。以提升客户品牌价值为核心业务,全程参与项目的网站策划设计制作,前端开发,后台程序制作以及后期项目运营并提出专业建议和思路。
一般情况下,在杀掉一个会话的时候,直接执行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怎么实现立即结束一个会话”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!
当前标题:ORACLE中altersystemkillsession怎么实现立即结束一个会话
文章位置:http://pwwzsj.com/article/giihdd.html