Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2108124
  • 博文数量: 333
  • 博客积分: 10161
  • 博客等级: 上将
  • 技术积分: 5238
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-19 08:59
文章分类

全部博文(333)

文章存档

2017年(10)

2014年(2)

2013年(57)

2012年(64)

2011年(76)

2010年(84)

2009年(3)

2008年(37)

分类: Oracle

2010-09-17 16:39:21

oracle查找并杀掉锁表及对象的session及相关系统进程
2008-10-22 22:23

一、处理过程
    1.通过查找出已被锁定的数据库表及相关的sid、serial#及spid:

     select object_name as 对象名称,s.sid,s.serial#,p.spid as 系统进程号
     from v$locked_object l , dba_objects o , v$session s , v$process p
     where l.object_id=o.object_id and l.session_id=s.sid and s.paddr=p.addr;

     2.在数据库中灭掉相关session:

    alter system kill session 'sid,serial#';

    --sid及serial#为第一步查出来的数据

     3.从系统中灭掉与该session对应的进程:

    kill -9 spid;

    --spid为第一步中查出来的系统进程号

    经过以上操作之后重新对之前锁定的对象进行操作应该就可以了。

二、使用了相关表的基本介绍

  • V$LOCKED_OBJECT中的列说明:
    XIDUSN:回滚段号
    XIDSLOT:槽号
    XIDSQN:序列号
    OBJECT_ID:被锁对象ID
    SESSION_ID:持有锁的sessionID
    ORACLE_USERNAME:持有锁的Oracle 用户名
    OS_USER_NAME:持有锁的操作系统 用户名
    PROCESS:操作系统进程号
    LOCKED_MODE:锁模式
  • dba_objects的列说明(网上找的,懒得翻译了^_^)
    OWNER
          Username of the owner of the object
       OBJECT_NAME
          Name of the object
       SUBOBJECT_NAME
          Name of the sub-object (for example,partititon)
       OBJECT_ID
          Object number of the object
       DATA_OBJECT_ID
          Object number of the segment which contains the object
       OBJECT_TYPE
          Type of the object
       CREATED
          Timestamp for the creation of the object
       LAST_DDL_TIME
          Timestamp for the last DDL change (including GRANT and REVOKE) to the object
       TIMESTAMP
          Timestamp for the specification of the object
       STATUS
          Status of the object
       TEMPORARY
          Can the current session only see data that it place in this object itself?
       GENERATED
          Was the name of this object system generated?
       SECONDARY
          Is this a secondary object created as part of icreate for domain indexes?
  • v$session的说明
    V$SESSION是基础信息视图,用于找寻用户SID或SADDR
    常用列:
    SID:SESSION标识
    SERIAL#:如果某个SID又被其它的session使用的话则此数值自增加(当一个SESSION结束,另一个SESSION开始并使用
    了同一个SID)。
    AUDSID:审查session ID唯一性,确认它通常也用于当寻找并行查询模式
    USERNAME:当前session在oracle中的用户名。
    STATUS:这列用来判断session状态是:
       Achtive:正执行SQL
    语句(waiting for/using a resource)
       Inactive:等待操作(即等待需要执行的SQL语句)
       Killed:被标注为删除
  • v$process视图
    v$process视图包含当前系统Oracle
    运行的所有进程信息。常被用于将Oracle或服务进程的操作系统
    进程ID与数据库session之间建立联系。
    常用列:
    ADDR:进程对象地址
    PID:oracle进程ID
    SPID:操作系统进程ID
  • 阅读(1721) | 评论(0) | 转发(0) |
    给主人留下些什么吧!~~