請確保您的會話沒有等待的行鎖。以下SQL * Plus腳本可以爲您提供有關如何執行此操作的提示。或者在Blocking Sessions下查看Oracle Enterprise Manager(Oracle Web GUI)。
BTW死鎖是不同的東西,數據庫會照顧殺死兩會的一個...
REM Purpose
REM -------
REM Display locks currently held and requested. Displays which session a
REM blocked lock is waiting for.
REM
REM Ver Who When What
REM --- --- ---- ----
REM 1.0 DrB 12-Dec-97 Initial version
col uname head "Username" form a12
col sid head "SID" form 999
col ltype head "Type" form a4
col lmode head "Mode" form a10
col blocked head "Wait" form a4
col details head "Details" form a40
set verify off
set pause on
accept user prompt "Username [%]: "
select SubStr('alter system kill session ''' || s.sid || ',' || s.serial# || ''';', 1, 40) as kill, s.username uname, 'DML' ltype,
decode (l.lmode,1,'Null',
2,'Row-S',
3,'Row-X',
4,'Share',
5,'S/Row-X',
6,'Exclusive') lmode,
decode (l.request,0,'No','Yes') blocked,
u.username||'.'||o.name details,
Nvl(s.Program, s.Module) What
from v$session s, v$lock l, sys.obj$ o, all_users u
where s.username like nvl(upper('&user'||'%'),'%')
and s.sid = l.sid
and l.id1 = o.obj#
--and l.type = 'TM'
and o.owner# = u.user_id(+)
union all
select SubStr('alter system kill session ''' || s.sid || ',' || s.serial# || ''';', 1, 40) as kill, s.username uname,
decode (l.type,'TX','TX',
'UL','USR',
'SYS') ltype,
decode (l.lmode,1,'Null',
2,'Row-S',
3,'Row-X',
4,'Share',
5,'S/Row-X',
6,'Exclusive') lmode,
decode (l.request,0,'No','Yes') blocked,
decode (l.request,0,null,'Waiting on session '||to_char(b.sid)) details,
Nvl(s.Program, s.Module) What
from v$session s, v$lock l, v$lock b
where s.username like nvl(upper('&user'||'%'),'%')
and s.sid = l.sid
and l.type != 'TM'
and l.id1 = b.id1(+)
and b.request(+) = 0
order by 5 desc,3 desc,2,1;
set verify on
REM End of file
你可以發佈存儲過程代碼和調用JDBC代碼嗎? – Nicholas 2011-05-17 13:39:02
我可以給你一些代碼的提示; – ttr13p 2011-05-26 10:29:49
不幸的是我不能打印代碼,但可以描述它。存儲過程非常複雜且效率不高。但它確實在sql開發人員中相對較快地終止; PROCEDURE stored_procedure(v_cur OUT SYS_REFCURSOR) IS BEGIN OPEN v_cur爲 WITH first_temp_table AS ( SELECT FROM <內部聯接但也有許多笛卡爾積> WHERE ) second_temp_table AS ( SELECT FROM <內連接,但也有很多笛卡爾產品> WHERE <使用first_temp_table>的子查詢> )<在臨時表上進行最終查詢選擇,具有非常複雜的不合理選擇和連接> – ttr13p 2011-05-26 10:53:39