个人技术分享

增加人员信息即死锁,排查过程如下(表名字为A001):

1、根据表查询死锁进程ID

select b.owner,b.object_name,a.session_id,a.locked_mode
from v$locked_object a,dba_objects b
where b.object_id = a.object_id and object_name='A080'

其中locked_mode:

"1":Select。
"2":Select for update,Lock For Update,Lock Row Share 
"3":Insert, Update, Delete, Lock Row Exclusive
"4":Create Index, Lock Share
locked_mode为2,3,4不影响DML(insert,delete,update,select)操作, 但DDL(alter,drop等)操作会提示ora-00054:"resource busy and acquire with NOWAIT specified"
"5"::Lock Share Row Exclusive 
"6":Alter table, Drop table, Drop Index, Truncate table, Lock Exclusive

2、根据ID查询进程具体信息

select b.username,b.sid,b.serial#,logon_time 
from v$session b
where sid='9'

这时可以杀进程

ALTER SYSTEM KILL SESSION '9,5' IMMEDIATE;

3、查死锁语句

SELECT s.sid, s.serial#, s.username, s.sql_id, s.sql_child_number, s.program, t.used_ublk
 FROM v$session s, v$transaction t
 WHERE s.saddr = t.ses_addr and sid='579'

不见得能查出,碰运气了