SELECTS.sid||','||S.serial# sid_serial, S.username, S.osuser, P.spid, S.module,S.program, SUM (T.blocks) *TBS.block_size/1024/1024 mb_used, T.tablespace,
COUNT(*) sort_ops
FROM v$sort_usage T, v$session S, dba_tablespaces TBS, v$process P
WHERET.session_addr=S.saddrANDS.paddr=P.addrANDT.tablespace=TBS.tablespace_nameGROUP BYS.sid, S.serial#, S.username, S.osuser, P.spid, S.module,S.program, TBS.block_size, T.tablespaceORDER BY sid_serial;
Listing Enabled Events
SET SERVEROUTPUT ON
DECLARE
l_level NUMBER;
BEGIN
FOR l_event IN10000..60999
LOOP
dbms_system.read_ev (l_event,l_level);
IF l_level >0 THEN
dbms_output.put_line ('Event '||TO_CHAR (l_event)||' is set at level '||TO_CHAR (l_level));
END IF;
END LOOP;
END;
/
Oracle sql get top n for each group
select*from (select emp_id, name, occupation,
rank() over ( partition by occupation order by emp_id) rank
from employee)
where rank <=3