ITPub博客

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

原创 Linux操作系统 作者:yxyup 时间:2007-03-18 00:00:00 0 删除 编辑

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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
暂无介绍

注册时间:2007-12-06

  • 博文量
    164
  • 访问量
    1314250