Skip to content
December 20, 2016 / doganay

BLOCKING-BLOCKED SESSIONS TREE SQL

--Session is displayed as -
with lk as (select blocking_instance||'-'||blocking_session blocker, inst_id||'-'||sid waiter 
from gv$session where blocking_instance is not null and blocking_session is not null)
select lpad(' ',2*(level-1))||waiter "Displayed as -" from
(select * from lk
union all
select distinct 'root', blocker from lk
where blocker not in (select waiter from lk))
connect by prior waiter=blocker start with blocker='root';
prompt

sample output:

Displayed as -
--------------------------------
1-855
  1-619
    1-548
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: