Oracle锁表了如何处理

[解决方法]

1)通过查找已被锁定的数据库表以及相关的sid,serial#,spid;

select object_name,s.sid,s.serial#,p.spid 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)杀死对应的应用程序

kill -9 spid

 

执行步骤演示:

[1] % sqlplus "/as sysdba"

 

SQL*Plus: Release 11.1.0.6.0 - Production on Fri Nov 26 09:10:32 2010

 

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production

With the Partitioning and Real Application Testing options

 

SQL> select object_name,o.owner,s.sid,s.serial#,p.spid 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;

 

OBJECT_NAME  OWNER  SID    SERIAL#  SPID 

-------------        -------    ----------  ----------  ------

EXTTEST         LYJ       139     221    26402

 

SQL> !ps -ef|grep 26402

  oracle 27588  5389  1 10:29:37 pts/tc    0:00 /usr/bin/csh -c ps -ef|grep 26402

  oracle 26402 26401  0 10:25:25 ?         0:00 oracleora11g (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))

  oracle 27590 27588  0 10:29:37 pts/tc    0:00 grep 26402

 

说明:根据上面查询出来的sid,serial#,杀死Session

SQL> alter system kill session '139,221';

 

System altered.

 

说明:可以看到Session杀死后,已经查询不到锁的对象;

SQL>  select object_name,o.owner,s.sid,s.serial#,p.spid 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;

 

no rows selected

 

说明:可以看到Session杀死后,进程依然存在;

SQL> !ps -ef|grep 26402

  oracle 27951 27949  0 10:30:49 pts/tc    0:00 grep 26402

  oracle 27949  5389  1 10:30:49 pts/tc    0:00 /usr/bin/csh -c ps -ef|grep 26402

  oracle 26402 26401  0 10:25:25 ?         0:00 oracleora11g (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))

 

说明:根据进程PID杀死进程;

SQL> !kill -9 26402

 

SQL> !ps -ef|grep 26402

  oracle 28110 28108  0 10:31:25 pts/tc    0:00 grep 26402

  oracle 28108  5389  1 10:31:25 pts/tc    0:00 /usr/bin/csh -c ps -ef|grep 26402

转载于:https://www.cnblogs.com/aoyihuashao/archive/2012/09/10/2678392.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值