ORACLE在windows上使用orakill结束oracle会话的线程

在windows上使用orakill结束oracle会话的线程     
   由于oracle在windows平台采用了单进程多线程的实现方式,unix/linux上的server process在windows上
实际是一个thread。我们知道,在unix平台上,有时使用alter system kill的方式杀死一个用户会话后,
可能会标记为killed而不是立即释放该会话所占有的所有资源,或者由于某些原因,某些会话处于假死状态,
这时可能要在os级别强行kill对应的process。但在windows上,进程管理器中只能看到一个oracle进程,而
无法看到并且杀死具体的线程。

       这种情况下,我们当然可以借助第三方的线程管理工具来实现我们杀某个指定线程的目的,但实际上,oracle
本身也是提供了这种的工具的。这就是orakill工具。orakill的用法很简单,两个参数,第一个是oracle_sid,
第二个是线程号,也就是oracle的v$process中的spid:

C:\Documents and Settings\Administrator>orakill

Usage:  orakill sid thread

  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

C:\Documents and Settings\Administrator>


SQL> desc v$process;
 名称                                      是否为空? 类型
 ----------------------------------------- -------- ----------------------------
 ADDR                                               RAW(4)
 PID                                                NUMBER
 SPID                                               VARCHAR2(24)
 USERNAME                                           VARCHAR2(15)
 SERIAL#                                            NUMBER
 TERMINAL                                           VARCHAR2(16)
 PROGRAM                                            VARCHAR2(64)
 TRACEID                                            VARCHAR2(255)
 TRACEFILE                                          VARCHAR2(513)
 BACKGROUND                                         VARCHAR2(1)
 LATCHWAIT                                          VARCHAR2(8)
 LATCHSPIN                                          VARCHAR2(8)
 PGA_USED_MEM                                       NUMBER
 PGA_ALLOC_MEM                                      NUMBER
 PGA_FREEABLE_MEM                                   NUMBER
 PGA_MAX_MEM                                        NUMBER

SQL> col spid for a10;
SQL> col program  for a30;
SQL> select spid,program from v$process;

SPID       PROGRAM                                                             
---------- ------------------------------                                      
           PSEUDO                                                              
24880      ORACLE.EXE (PMON)                                                   
24884      ORACLE.EXE (VKTM)                                                   
24888      ORACLE.EXE (DIAG)                                                   
24892      ORACLE.EXE (DBRM)                                                   
24896      ORACLE.EXE (PSP0)                                                   
25028      ORACLE.EXE (MMAN)                                                   
23216      ORACLE.EXE (DIA0)                                                   
25036      ORACLE.EXE (DBW0)                                                   
25044      ORACLE.EXE (LGWR)                                                   
25040      ORACLE.EXE (CKPT)                                                   

SPID       PROGRAM                                                             
---------- ------------------------------                                      
25048      ORACLE.EXE (SMON)                                                   
25052      ORACLE.EXE (RECO)                                                   
25056      ORACLE.EXE (MMON)                                                   
25060      ORACLE.EXE (MMNL)                                                   
25064      ORACLE.EXE (D000)                                                   
25276      ORACLE.EXE (S000)                                                   
36532      ORACLE.EXE (SHAD)                                                   
25868      ORACLE.EXE (ARC0)                                                   
25864      ORACLE.EXE (ARC1)                                                   
25872      ORACLE.EXE (ARC2)                                                   
25984      ORACLE.EXE (ARC3)                                                   

SPID       PROGRAM                                                             
---------- ------------------------------                                      
24916      ORACLE.EXE (FBDA)                                                   
25068      ORACLE.EXE (SMCO)                                                   
25956      ORACLE.EXE (QMNC)                                                   
34960      ORACLE.EXE (W000)                                                   
26252      ORACLE.EXE (q001)                                                   
26496      ORACLE.EXE (CJQ0)                                                   
26456      ORACLE.EXE (q000)                                                   

已选择29行。

SQL> select  spid,osuser,s.program from v$process p,v$session  s
  2  where p.addr=s.paddr
  3  and p.program like '%ARC%';

SPID       OSUSER                         PROGRAM                              
---------- ------------------------------ ------------------------------       
25868      SYSTEM                         ORACLE.EXE (ARC0)                    
25864      SYSTEM                         ORACLE.EXE (ARC1)                    
25872      SYSTEM                         ORACLE.EXE (ARC2)                    
25984      SYSTEM                         ORACLE.EXE (ARC3)                    

SQL> host
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

C:\>orakill ticket 25868

Kill of thread id 25868 in instance ticket successfully signalled.

C:\>exit

SQL> spool off;

你可能感兴趣的:(windows)