oracle查询被锁定的表:
SELECT p.spid,c.object_name,b.session_id,a.serial#,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;
解除表的锁定:
DECLARE S_CMD VARCHAR2(2000); BEGIN FOR X IN (SELECT p.spid,all_objects c WHERE p.addr = a.paddr AND a.process = b.process AND c.object_id = b.object_id) LOOP S_CMD := ''''||X.SESSION_ID||','||X.SERIAL#||''''; BEGIN execute immediate 'alter system kill session '||S_CMD; exception when others then DBMS_OUTPUT.PUT_LINE(sqlCODE||'---'||sqlERRM); end; END LOOP; END;原文链接:https://www.f2er.com/oracle/206688.html