kill session

An active session cannot be interrupted whenit is performing network I/O or rolling 
back a transaction.
Such a session cannot beterminated until the operation completes. 
In this case, the session holds all resources until it is terminated. Additionally, the 
session that issues the ALTER SYSTEMstatement to terminate a session waits up to 60 
seconds for the session to be terminated. Ifthe operation that cannot be interrupted 
continues past one minute, the issuer of the ALTER SYSTEMstatement receives a 
message indicating that the session has been marked to be terminated. A session 
marked to be terminated is indicated in V$SESSIONwith a status of KILLEDand a 

server that is something other than PSEUDO.


一个执行network I/O与rollback的会话不能中断直到操作完成,执行alter system

kill ……的会话会在一分钟后收到被“ORA-00031: session marked for kill“的提示,

并且被kill的会话状态为killed。

下面我们以rollback为例进行说明


session 1:

SQL> insert into huang select * from huang;

100632 rows created.

SQL> /

201264 rows created.

SQL> /

402528 rows created.

SQL> /

805056 rows created.

SQL> /

1610112 rows created.

SQL> SELECT SID FROM V$MYSTAT WHERE ROWNUM =1
  2  ;

       SID
----------
       147

SQL> delete from huang;

3220224 rows deleted.

SQL> rollback;

session 2

SQL> select SID ,SERIAL# , STATUS  from v$session where username='HR';

       SID    SERIAL# STATUS
---------- ---------- ----------------
       159         48 ACTIVE

SQL> show user
USER is "HR"
SQL>  select SID ,SERIAL# , STATUS  from v$session where username='HR';

       SID    SERIAL# STATUS
---------- ---------- ----------------
       147         24 INACTIVE
       159         48 ACTIVE

SQL> alter system kill session '147,24';
alter system kill session '147,24'
*
ERROR at line 1:
ORA-00031: session marked for kill


SQL>  select SID ,SERIAL# , STATUS  from v$session where username='HR';

       SID    SERIAL# STATUS
---------- ---------- ----------------
       147       <span style="color:#ff0000;">  24 KILLED</span>
       159         48 ACTIVE



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

huangliang0703

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值