您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“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怎么實現立即結束一個會話”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。