반응형

SELECT b.username "Oracle User", a.spid "Unix PID", b.SID "Oracle Sid",

       b.serial# "Oracle Serial", b.osuser "OS User", b.machine "Computer",

       b.program "Program",

       TO_CHAR (logon_time, 'HH24:MI:SS,yyyy/mm/dd') "Login Time",

       b.action "Session Action", c.action "SQL Action", lockwait "LockWait",

       status "Status", optimizer_cost "Optimizer_cost",

       c.sql_text "SQL Text"

  FROM v$process a, v$session b, v$sql c

 WHERE

       --spid=&PID and

       a.addr = b.paddr

   AND b.sql_address = c.address

   AND b.sql_hash_value = c.hash_value;


-----------------

SELECT b.username "Oracle User", b.SID "Oracle Sid",

       b.serial# "Oracle Serial", b.osuser "OS User", b.machine "Computer",

       b.program "Program",

       TO_CHAR (logon_time, 'HH24:MI:SS,yyyy/mm/dd') "Login Time",

       b.action "Session Action", c.action "SQL Action", lockwait "LockWait",

       status "Status", optimizer_cost "Optimizer_cost",

       c.sql_text "SQL Text"

  FROM v$session b, v$sql c

 WHERE b.sql_address = c.address AND b.sql_hash_value = c.hash_value;



 ----------------


 SELECT BS.USERNAME "Blocking User",

 

BS.USERNAME "DB User",

 

WS.USERNAME "Waiting User",

 

BS.SID "SID",

 

WS.SID "WSID",

 

BS.SERIAL# "Serial#",

 

BS.SQL_ADDRESS "address",

 

BS.SQL_HASH_VALUE "Sql hash",

 

BS.PROGRAM "Blocking App",

 

WS.PROGRAM "Waiting App",

 

BS.MACHINE "Blocking Machine",

 

WS.MACHINE "Waiting Machine",

 

BS.OSUSER "Blocking OS User",

 

WS.OSUSER "Waiting OS User",

 

BS.SERIAL# "Serial#",

 

WS.SERIAL# "WSerial#",

 

DECODE(WK.TYPE,'MR','Media Recovery',

 

'RT','Redo Thread',

 

'UN','USER Name',

 

'TX','Transaction',

 

'TM','DML',

 

'UL','PL/SQL USER LOCK',

 

'DX','Distributed Xaction',

 

'CF','Control FILE',

 

'IS','Instance State',

 

'FS','FILE SET',

 

'IR','Instance Recovery',

 

'ST','Disk SPACE Transaction',

 

'TS','Temp Segment',

 

'IV','Library Cache Invalidation',

 

'LS','LOG START OR Switch',

 

'RW','ROW Wait',

 

'SQ','Sequence Number',

 

'TE','Extend TABLE',

 

'TT','Temp TABLE',

 

WK.TYPE) LOCK_TYPE,

 

DECODE(HK.LMODE,0,'None',

 

1,'NULL',

 

2,'ROW-S (SS)',

 

3,'ROW-X (SX)',

 

4,'SHARE',

 

5,'S/ROW-X (SSX)',

 

6,'EXCLUSIVE',

 

TO_CHAR(HK.LMODE)) MODE_HELD,

 

DECODE(WK.REQUEST,0,'None',

 

1,'NULL',

 

2,'ROW-S (SS)',

 

3,'ROW-X (SX)',

 

4,'SHARE',

 

5,'S/ROW-X (SSX)',

 

6,'EXCLUSIVE',

 

TO_CHAR(WK.REQUEST)) MODE_REQUESTED,

 

TO_CHAR(HK.ID1) LOCK_ID1,

 

TO_CHAR(HK.ID2) LOCK_ID2,

 

DECODE(HK.BLOCK,0,'NOT Blocking', /* Not blocking any other processes */

 

1,'Blocking', /* This lock blocks other processes */

 

2,'Global', /* This lock is global, so we can't tell */

 

TO_CHAR(HK.BLOCK)) BLOCKING_OTHERS

 

FROM V$LOCK HK,

 

V$SESSION BS,

 

V$LOCK WK,

 

V$SESSION WS

 

WHERE HK.BLOCK = 1

 

AND HK.LMODE != 0

 

AND HK.LMODE != 1

 

AND WK.REQUEST != 0

 

AND WK.TYPE (+) = HK.TYPE

 

AND WK.ID1 (+) = HK.ID1

 

AND WK.ID2 (+) = HK.ID2

 

AND HK.SID = BS.SID (+)

 

AND WK.SID = WS.SID (+)

 

AND (BS.USERNAME IS NOT NULL)

 

AND (BS.USERNAME <> 'SYSTEM')

 

AND (BS.USERNAME <> 'SYS')

 

ORDER BY 1;




------------



SELECT c.owner, c.object_name, c.object_type,

       fu.user_name locking_fnd_user_name,

       fl.start_time locking_fnd_user_login_time, vs.module, vs.machine,

       vs.osuser, vlocked.oracle_username, vs.SID, vp.pid,

       vp.spid AS os_process, vs.serial#, vs.status, vs.saddr, vs.audsid,

       vs.process

  FROM fnd_logins fl,

       fnd_user fu,

       v$locked_object vlocked,

       v$process vp,

       v$session vs,

       dba_objects c

 WHERE vs.SID = vlocked.session_id

   AND vlocked.object_id = c.object_id

   AND vs.paddr = vp.addr

   AND vp.spid = fl.process_spid(+)

   AND vp.pid = fl.pid(+)

   AND fl.user_id = fu.user_id(+)

   AND c.object_name LIKE '%' || UPPER ('&tab_name_leaveblank4all') || '%'

   AND NVL (vs.status, 'XX') != 'KILLED'; --<-change it 

반응형

+ Recent posts