转自:http://blog.csdn.net/zhldt2008/article/details/7953932
1. 如下语句 查询锁定的表:
SELECT l.session_id sid, s.serial#, l.locked_mode,l.oracle_username,
l.os_user_name,s.machine, s.terminal, o.object_name, s.logon_time
FROM v$locked_object l, all_objects o, v$session s
WHERE l.object_id = o.object_id
AND l.session_id = s.sid
ORDER BY sid, s.serial# ;
2.然后删除掉系统锁定的此记录
ALTER system KILL session 'SID,serial#';
如果有多个sid 和serial# 重复删除每条记录
3.循环释放锁表资源
DECLare str VARCHAR2(1000);
BEGIN
FOR c1 in (
SELECT l.session_id sid, s.serial#, l.locked_mode,l.oracle_username,
l.os_user_name,s.machine, s.terminal, o.object_name, s.logon_time
FROM v$locked_object l, all_objects o, v$session s
WHERE l.object_id = o.object_id
AND l.session_id = s.sid
) LOOP
str:='ALTER system KILL session '''||c1.sid||','||c1.serial#||'''';
EXECUTE IMMEDIATE str;
commit;
END LOOP;
END;