這篇文章主要為大家展示了“ORACLE中alter system kill session怎么實(shí)現(xiàn)立即結(jié)束一個(gè)會(huì)話”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“ORACLE中alter system kill session怎么實(shí)現(xiàn)立即結(jié)束一個(gè)會(huì)話”這篇文章吧。
成都創(chuàng)新互聯(lián)是一家成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作,提供網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),網(wǎng)站制作,建網(wǎng)站,按需網(wǎng)站開發(fā),網(wǎng)站開發(fā)公司,公司2013年成立是互聯(lián)行業(yè)建設(shè)者,服務(wù)者。以提升客戶品牌價(jià)值為核心業(yè)務(wù),全程參與項(xiàng)目的網(wǎng)站策劃設(shè)計(jì)制作,前端開發(fā),后臺(tái)程序制作以及后期項(xiàng)目運(yùn)營(yíng)并提出專業(yè)建議和思路。
一般情況下,在殺掉一個(gè)會(huì)話的時(shí)候,直接執(zhí)行alter system kill session ‘sid,serial#’; 隨后進(jìn)行查詢發(fā)現(xiàn),被KILL掉的會(huì)話狀態(tài)變?yōu)镵ILLED狀態(tài),并沒(méi)有立即結(jié)束,稍后再次查詢?cè)摃?huì)話,確認(rèn)已經(jīng)結(jié)束。如果希望立即結(jié)束一個(gè)會(huì)話,如何處理?
經(jīng)過(guò)查詢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.
當(dāng)session是active的時(shí)候,alter system kill session 只是將session標(biāo)識(shí)為killed狀態(tài),并不會(huì)釋放session持有的資源,所以我們?cè)趫?zhí)行完alter system kill session 后,看會(huì)話還是一直存在,等待PMON進(jìn)程回收資源和釋放鎖等。
如果:
不加IMMEDIATE,僅僅是標(biāo)記該事務(wù)為中斷,等待PMON進(jìn)程來(lái)回收該SESSION所占用的資源及釋放鎖等;
加IMMEDIATE, 即在alter system kill session 'sid,serial,@sid' 后增加 immediate來(lái)實(shí)現(xiàn)立即結(jié)束會(huì)話。
以上是“ORACLE中alter system kill session怎么實(shí)現(xiàn)立即結(jié)束一個(gè)會(huì)話”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!