The query formats the v$lock.ctime column from seconds to hours minutes and seconds.
COLUMN "Hr:Min:Sec" FORMAT A12
WITH data AS
( SELECT s.username,
MAX(l.ctime) lockSecs
FROM v$session s,
v$lock l
WHERE s.sid = l.sid
GROUP BY s.username )
SELECT username,
LPAD(TRUNC(lockSecs/3600),6)||':'
||LPAD(MOD(TRUNC(lockSecs/60),60),2,'0')||':'
||LPAD(MOD(lockSecs,60),2,'0') "Hr:Min:Sec"
FROM data
ORDER BY lockSecs DESC
;
WITH data AS
( SELECT s.username,
MAX(l.ctime) lockSecs
FROM v$session s,
v$lock l
WHERE s.sid = l.sid
GROUP BY s.username )
SELECT username,
LPAD(TRUNC(lockSecs/3600),6)||':'
||LPAD(MOD(TRUNC(lockSecs/60),60),2,'0')||':'
||LPAD(MOD(lockSecs,60),2,'0') "Hr:Min:Sec"
FROM data
ORDER BY lockSecs DESC
;
Done.
No comments:
Post a Comment