SELECT DECODE(TRUNC(SYSDATE - LOGON_TIME), 0, NULL, TRUNC(SYSDATE - LOGON_TIME)
|| ' Days'
|| ' + ')
|| TO_CHAR(TO_DATE(TRUNC(MOD(SYSDATE-LOGON_TIME,1) * 86400), 'SSSSS'), 'HH24:MI:SS') LOGON,
s.SID SID,
s.serial#,
p.spid SPID,
s.status,
s.username,
UPPER(DECODE(command, 1,'Create Table',2,'Insert',3,'Select', 4,'Create Cluster',5,'Alter Cluster',6,'Update', 7,'Delete', 8,'Drop Cluster', 9,'Create Index', 10,'Drop Index', 11,'Alter Index', 12,'Drop Table', 13,'Create Sequencfe', 14,'Alter Sequence', 15,'Alter Table', 16,'Drop Sequence', 17,'Grant', 18,'Revoke', 19,'Create Synonym', 20,'Drop Synonym', 21,'Create View', 22,'Drop View', 23,'Validate Index', 24,'Create Procedure', 25,'Alter Procedure', 26,'Lock Table', 27,'No Operation', 28,'Rename', 29,'Comment', 30,'Audit', 31,'NoAudit', 32,'Create Database Link', 33,'Drop db Link', 34,'Create Database', 35,'Alter Database', 36,'Create Rollback Segment', 37,'Alter Rollback Segment', 38,'Drop Rollback Segment', 39,'Create Tablespace', 40,'Alter Tablespace', 41,'Drop Tablespace', 42,'Alter Sessions', 43,'Alter User', 44,'Commit', 45,'Rollback', 46,'Savepoint', 47,'PL/SQL Execute', 48,'Set Transaction', 49,'Alter System Switch Log', 50,'Explain Plan', 51,'Create User', 52,
'Create Role', 53,'Drop User', 54,'Drop Role', 55,'Set Role', 56,'Create Schema', 57,'Create Control File', 58,'Alter Tracing', 59,'Create Trigger', 60,'Alter Trigger', 61,'Drop Trigger', 62,'Analyze Table', 63,'Analyze Index', 64,'Analyze Cluster', 65,'Create Profile', 66,'Drop Profile', 67,'Alter Profile', 68,'Drop Procedure', 69,'Drop Procedure', 70,'Alter Resource Cost', 71,'Create Snapshot Log', 72,'Alter Snapshot Log', 73,'Drop Snapshot Log', 74,'Create Snapshot', 75,'Alter Snapshot', 76,'Drop Snapshot', 79,'Alter Role', 85,'Truncate Table', 86,'Truncate Cluster', 88,'Alter View', 91,'Create Function', 92,'Alter Function', 93,'Drop Function', 94,'Create Package', 95,'Alter Package', 96,'Drop Package', 97,'Create Package Body', 98,'Alter Package Body', 99,'Drop Package Body')) command,
ROUND((RATIO_TO_REPORT(t.VALUE) OVER ())*100, 2) AS CPU_PERC,
s.machine
|| '('
|| s.osuser
|| ')' machine_osuser,
s.program,
s.module,
t.VALUE CPU_value,
a.sql_fulltext
FROM v$session s,
v$sesstat t,
v$statname n,
v$process p,
v$sqlarea a
WHERE s.SID = t.SID
AND p.addr = s.paddr
AND t.statistic# = n.statistic#
AND n.NAME = 'CPU used by this session'
AND t.VALUE > 0
--AND s.status = 'ACTIVE'
AND audsid > 0 and a.hash_value = s.sql_hash_value
ORDER BY t.VALUE DESC
No comments:
Post a Comment