查看oracle锁的表名
发布网友
发布时间:2022-04-23 23:41
我来回答
共3个回答
热心网友
时间:2022-04-08 03:42
下面3个语句是我经常使用来解决oracle锁问题的 -- 注意你的用户有没有权限问题
1. 查看被锁的表
SELECT p.spid, a.serial#, c.object_name, b.session_id, b.oracle_username,
b.os_user_name
FROM v$process p, v$session a, v$locked_object b, all_objects c
WHERE p.addr = a.paddr AND a.process = b.process
AND c.object_id = b.object_id
2. 查看是哪个进程锁的
SELECT sid, serial#, username, osuser FROM v$session where osuser = 'tangpj'
3. 杀掉这个进程 alter system kill session 'sid,serial#';
热心网友
时间:2022-04-08 05:00
查看哪个表被锁
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
查看是哪个session引起的
select b.username,b.sid,b.serial#,logon_time
from v$locked_object a,v$session b
where a.session_id = b.sid order by b.logon_time
热心网友
时间:2022-04-08 06:35
SELECT S.SID SESSION_ID, S.USERNAME, DECODE(LMODE, 0 , ' None ' , 1 , ' Null ' , 2 , ' Row-S (SS) ' , 3 , ' Row-X (SX) ' , 4 , ' Share ' , 5 , ' S/Row-X (SSX) ' , 6 , ' Exclusive ' , TO_CHAR(LMODE)) MODE_HELD, DECODE(REQUEST, 0 , ' None ' , 1 , ' Null ' , 2 , ' Row-S (SS) ' , 3 , ' Row-X (SX) ' , 4 , ' Share ' , 5 , ' S/Row-X (SSX) ' , 6 , ' Exclusive ' , TO_CHAR(REQUEST)) MODE_REQUESTED, O.OWNER || ' . ' || O. OBJECT_NAME || ' ( ' || O.OBJECT_TYPE || ' ) ' , S.TYPE LOCK_TYPE, L.ID1 LOCK_ID1, L.ID2 LOCK_ID2
FROM V$LOCK L, SYS.DBA_OBJECTS O, V$SESSION S
WHERE L.SID = S.SID AND L.ID1 = O. OBJECT_ID
执行上记SQL语句,可以查寻到数据库中的锁的情报.
SESSION_ID, USERNAME, MODE_HELD, MODE_REQUESTED, OBJECT_NAME, LOCK_TYPE, LOCK_ID
分别是 拥有锁的SESSION_ID,拥有锁的USERNAME,锁的执行模式MODE_HELD,锁的请求MODE_REQUESTED,锁所在的数据库对象名
,锁的类型,锁的ID