Find a blocking session and kill it


/ Published in: SQL
Save to your folder(s)

La première commande liste les sessions bloquantes, la deuxième les kill


Copy this code and paste it in your HTML
  1. SELECT s1.username || '@' || s1.machine
  2. || ' ( SID=' || s1.sid || ' ) is blocking '
  3. || s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_status
  4. FROM v$lock l1, v$session s1, v$lock l2, v$session s2
  5. WHERE s1.sid=l1.sid AND s2.sid=l2.sid
  6. AND l1.BLOCK=1 AND l2.request > 0
  7. AND l1.id1 = l2.id1
  8. AND l2.id2 = l2.id2 ;
  9.  
  10. ------------------------------------------------------------------
  11.  
  12. ALTER system KILL SESSION '<sid>,<serial#>' IMMEDIATE ;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.