session

--*******SESSION*********start***
--打开一个回话sid=136
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Administrator>cd \
C:\>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jul 23 20:13:32 2014
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
20:13:32 SYS@jzt>select distinct sid from v$mystat;--当前回话的sid=136
       SID
----------
       136
20:13:54 SYS@jzt>select sid,serial# from v$session where sid='136';--当前回话所对应的服务线程值=921
       SID SERIAL#
---------- ----------
       136 921
20:14:29 SYS@jzt>alter system kill '136,921'immediate;--自己kill不了自己的回话
alter system kill '136,921'immediate *
ERROR at line 1:
ORA-02000: missing SESSION keyword
       
---开启另外一个窗口回话sid=67
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Administrator>cd\
C:\>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jul 23 20:31:30 2014
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
20:31:30 SYS@jzt>select distinct sid from v$mystat;--当前sid=67
       SID
----------
        67
20:36:17 SYS@jzt>alter system kill session'136,921'immediate;
System altered.
--验证回话sid=136是否被Kill掉
20:15:26 SYS@jzt>select distinct sid from v$mystat;
select distinct sid from v$mystat
                  *
ERROR at line 1:
ORA-03113: end-of-file on communication channel--kill了
Process ID: 9688
Session ID: 136 Serial number: 921
20:37:33 SYS@jzt>select count(*) from scott.emp;
ERROR:
ORA-03114: not connected to ORACLE--kill了
20:38:04 SYS@jzt>conn / as sysdba--重新连接
Connected.
20:38:37 SYS@jzt>select distinct sid from v$mystat;--当前sid=135,136已经被kill
       SID
----------
       135
20:38:41 SYS@jzt>select count(*) from scott.emp;--正常回话
  COUNT(*)
----------
        12
--继续sid=135的回话,使用开启的下一个窗口sid=11的会话来做orakill的实验 orakill sid thread
20:44:37 SYS@jzt>select sid,serial# from v$session where sid='135'
20:56:02 2 ;--当前sid的线程=233
       SID SERIAL#
---------- ----------
       135 233
       
--开启第三个窗口回话sid=11
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Administrator>cd\
C:\>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jul 23 20:54:32 2014
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
20:54:33 SYS@jzt>select distinct sid from v$mystat;--当前sid=11
       SID
----------
        11
20:54:49 SYS@jzt>host orakill;--切换到os命令,查看orakill的使用方法(仅在windows下使用)
Usage: orakill sid thread --sid:system indentifier
  where sid = the Oracle instance to target
        thread = the thread id of the thread to kill
  The thread id should be retrieved from the spid column of a query such as:
        select spid, osuser, s.program from
        v$process p, v$session s where p.addr=s.paddr
20:55:01 SYS@jzt>select instance_name from v$instance;--数据库sid=jzt
INSTANCE_NAME
----------------
jzt
20:56:46 SYS@jzt>host orakill jzt 233;
Kill of thread id 233 in instance jzt successfully signalled.--orakill成功!
20:57:11 SYS@jzt>exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64
With the Partitioning, OLAP, Data Mining and Real Application Testing options
C:\>orakill jzt 223;--也成功!
Kill of thread id 223; in instance jzt successfully signalled.
--验证orakill是否成功! 继续sid=135
SYS@jzt>select distinct sid from v$mystat;
       SID
----------
       135
SYS@jzt>select count(*) from scott.emp;--sid=135 的正常连接使用 orakill失败!!!
  COUNT(*)
----------
        12
SYS@jzt>select distinct sid from v$mystat;--sid=135 的正常连接使用 orakill失败!!!
       SID
----------
       135
--*******SESSION*********end*** 

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

转载于:http://blog.itpub.net/29267792/viewspace-1225739/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值