alter system disconnect/kill session 'sid,serial#';

alter system disconnect 'sid,serial#';

1.session 1

SQL> conn yxy
Enter password:
Connected.
SQL> select * from t;

NUM
----------
1

SQL> update t set num=2 where num=1;

1 row updated.

2.session 2

SQL> select sid,serial#,username from v$session where type='USER';

SID SERIAL# USERNAME
---------- ---------- ------------------------------
10 1
11 1
15 21625 SYS
20 9893 YXY

SQL> select a.sid,a.serial#,a.username,b.spid from v$session a,v$process b where a.paddr=b.addr and a.sid=20;

SID SERIAL# USERNAME SPID
---------- ---------- ------------------------------ ------------
20 9907 YXY 27596


SQL> alter system disconnect session '20,9907' immediate;

System altered.


SQL> host
[oracle@restore ~]$ ps -ef | grep 27596
oracle 27596 27594 0 20:01:30 ? 0:00 oracleoramdb (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 27693 27690 0 20:06:38 pts/ta 0:00 grep 27596

3.session 1

SQL> r
1* update t set num=2 where num=1
update t set num=2 where num=1
*
ERROR at line 1:
ORA-00028: your session has been killed

SQL> exit
[oracle@restore ~]$

4.session 2

[oracle@restore ~]$ ps -ef | grep 27596
oracle 27697 27690 0 20:06:47 pts/ta 0:00 grep 27596
[oracle@restore ~]$ ps -ef | grep 27596
[oracle@restore ~]$ ps -ef | grep 27596
oracle 27771 27690 1 20:06:51 pts/ta 0:00 grep 27596

alter system kill session 'sid,serial#';

1.session 1

SQL> update t set num=2 where num=1;

1 row updated.


2.session 2
SQL> select a.sid,a.serial#,a.username,b.spid from v$session a,v$process b where a.paddr=b.addr and a.sid=20;

SID SERIAL# USERNAME SPID
---------- ---------- ------------------------------ ------------
20 9939 YXY 27887


SQL> alter system kill session '20,9939' immediate;

System altered.


SQL> host
[oracle@restore ~]$ ps -ef | grep 27887
oracle 27974 27972 0 20:19:13 pts/ta 0:00 grep 27887
oracle 27887 27871 0 20:15:54 ? 0:00 oracleoramdb (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
[oracle@restore ~]$ ps -ef | grep 27887
oracle 27887 27871 0 20:15:54 ? 0:00 oracleoramdb (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 27976 27972 0 20:19:24 pts/ta 0:00 grep 27887


2.session 1

SQL> r
1* update t set num=2 where num=1
update t set num=2 where num=1
*
ERROR at line 1:
ORA-00028: your session has been killed


SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.5.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.5.0 - Production
[oracle@restore ~]$ sqlplus /nolog

SQL*Plus: Release 9.2.0.5.0 - Production on Sat Mar 17 20:20:02 2007

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

SQL> conn yxy
Enter password:
Connected.
SQL> select * from t;

NUM
----------
1

3.session 2

[oracle@restore ~]$ ps -ef | grep 27887
oracle 27979 27972 0 20:19:41 pts/ta 0:00 grep 27887


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7364032/viewspace-17458/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7364032/viewspace-17458/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值