Skip to content

Instantly share code, notes, and snippets.

@kshimi
Created March 14, 2019 10:01
Show Gist options
  • Save kshimi/6ab9f72d670b57abd62fef6a747f5291 to your computer and use it in GitHub Desktop.
Save kshimi/6ab9f72d670b57abd62fef6a747f5291 to your computer and use it in GitHub Desktop.
Oracle check lock status
select
l.type
,ltype.Name
,ltype.description
,decode(l.lmode,
1, 'Null',
2, '行共有(SS)',
3, '行排他(SX)',
4, '共有(S)',
5, '共有/行排他(SSX)',
6, '排他(X)',
l.lmode) 保持ロックモード
,decode(l.request,
1, 'Null',
2, '行共有(SS)',
3, '行排他(SX)',
4, '共有(S)',
5, '共有/行排他(SSX)',
6, '排他(X)',
l.request) 要求ロックモード
,l.ctime
,l.block
,decode(l.block,
0, '他のプロセスをブロックしていない',
1, '他のプロセスをブロックしている',
l.block) ブロック状態
,l.sid
,s.serial#
,s.username
,s.schemaname
,sql.command_type
,sql.sql_text
from
v$lock l
inner join v$session s on l.sid = s.sid
left join v$lock_type ltype on l.type = ltype.type
left join v$sqltext sql on s.sql_id = sql.sql_id
where
l.type not in ('AE')
and s.schemaname = 'AP21_APX'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment