i漂泊

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 5500|回复: 0

Oracle pl/sql 死锁解决办法

[复制链接]
TA的礼物信息
  • 收到:0
  • 送出:2
发表于 2012-12-18 13:45:40 | 显示全部楼层 |阅读模式
查询当前数据库锁的sql:
  1. select b.owner,
  2.        b.object_name,
  3.        a.session_id,
  4.        a.locked_mode,
  5.        c.SERIAL#,
  6.        c.LOGON_TIME
  7.   from v$locked_object a, dba_objects b, V$SESSION c
  8. where b.object_id = a.object_id
  9.    and a.SESSION_ID = c.SID;
复制代码
查询造成锁的SQL为:
  1. select sql_text
  2.   from v$session, v$sqltext_with_newlines
  3. where decode(v$session.sql_hash_value, 0, prev_hash_value, sql_hash_value) =
  4.        v$sqltext_with_newlines.hash_value
  5.    and v$session.sid = #SESSION_ID#
  6. order by piece;
复制代码
其中 #SESSION_ID# 为锁的会话ID
如果确定为死锁,可以使用下面语句杀死死锁
---杀掉死锁
alter system kill session 'SID,SERIAL#';

注意:使用以上语句干掉死锁,必须保证自己拥有相应的权限,不然会报 ora-01031  异常.

回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

QQ|小黑屋|手机版|IPiaoBo Inc. ( 渝ICP备17002826号 )

GMT+8, 2024-4-20 12:24 , Processed in 0.076736 second(s), 47 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表