重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1789|回复: 0
打印 上一主题 下一主题

[Oracle] alter system kill session会话不释放

[复制链接]
跳转到指定楼层
楼主
发表于 2022-2-20 15:18:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
一般情况下,在杀一个会话的时候,直接执行alter system kill session 'sid,serial#';
但是在数据库中发现了异常的inactive会话,通过上面的kill杀掉之后,会话被标记为killed状态,但是依然存在,没有释放
这时候就直接采用immediate选项,强制杀掉会话
Administrator's Guide上说,当session是active的时候,alter system kill session 只是将session标识为killed
或者pseudo状态,并不会释放session持有的资源,所以我们在执行完alter system kill session 后,看会话还
是一直存在。

可以使用 immediate选项,强制立即Kill会话,如下:
SQL> alter system kill session '3964,51752' immediate;
SQL Language Reference里对Immediate的解释是: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.

另外我们也可以使用alter system disconnect session
The POST_TRANSACTION setting allows ongoing transactions to complete before the session is disconnected.
If the session has no ongoing transactions, then this clause has the same effect described for as KILL SESSION.
The IMMEDIATE setting disconnects the session and recovers the entire session state immediately, without
waiting for ongoing transactions to complete.
  • If you also specify POST_TRANSACTION and the session has ongoing transactions, then the IMMEDIATE keyword is ignored.
  • If you do not specify POST_TRANSACTION, or you specify POST_TRANSACTION but the session has no ongoing transactions,
  • then this clause has the same effect as described for KILL SESSION IMMEDIATE.


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-6-17 11:37 , Processed in 0.100210 second(s), 21 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表