当前位置:Gxlcms > mysql > Oracle数据库查询对象是否被锁定及解锁

Oracle数据库查询对象是否被锁定及解锁

时间:2021-07-01 10:21:17 帮助过:61人阅读

Oracle数据库对象是否被锁定查询SQL及解锁过程SQL详见下面:

Oracle数据库对象是否被锁定查询SQL及解锁过程SQL详见下面:

--查询当前用户下被锁的对象
SELECT B.OBJECT_NAME, B.OWNER, C.SID,C.SERIAL#,C.OSUSER, C.MACHINE, C.TERMINAL
FROM V$LOCKED_OBJECT A, DBA_OBJECTS B, V$SESSION C
WHERE A.OBJECT_ID = B.OBJECT_ID
AND A.SESSION_ID = C.SID
AND c.STATUS='INACTIVE'
AND C.TYPE='USER'
ORDER BY 1;

--解锁语句
DECLARE
V_SQL VARCHAR2(500);
CURSOR C_SESSION IS
SELECT B.OBJECT_NAME,
B.OWNER,
C.SID AS SESSION_ID,
C.SERIAL# AS SERIAL#,
C.OSUSER,
C.MACHINE,
C.TERMINAL
FROM V$LOCKED_OBJECT A, DBA_OBJECTS B, V$SESSION C
WHERE A.OBJECT_ID = B.OBJECT_ID AND A.SESSION_ID = C.SID
AND C.STATUS = 'INACTIVE' AND C.TYPE = 'USER'
ORDER BY 1;
BEGIN
FOR GET_SESSION IN C_SESSION
LOOP
BEGIN
V_SQL:='ALTER SYSTEM KILL SESSION '''||GET_SESSION.SESSION_ID||','||GET_SESSION.SERIAL#||''' IMMEDIATE';
EXECUTE IMMEDIATE V_SQL;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END LOOP;
END;
/

Linux-6-64下安装Oracle 12C笔记

RHEL6.4_64安装单实例Oracle 12cR1

Oracle 12C新特性之翻页查询

解读 Oracle 12C 的 12 个新特性

本文永久更新链接地址:

linux

人气教程排行