@@header

/*
*
*  Author     : Vishal Gupta
*  Purpose    : Display Analytic Workspace (AW) Size
*  Parameters : NONE
*
*  Revision History:
*  ===================
*  Date       Author        Description
*  ---------  ------------  -----------------------------------------
*  30-Jul-12  Vishal Gupta  Created
*  
*/

PROMPT **********************************
PROMPT *  Analytic Workspace Size
PROMPT **********************************

COLUMN owner                                   HEADING ""                                 FORMAT a20
COLUMN aw_name                                 HEADING "AW Name"                          FORMAT a25
COLUMN aw_version                              HEADING "AW|Ver"                           FORMAT a5
COLUMN attach_mode                             HEADING "Attach|Mode"                      FORMAT a5
COLUMN session_id                              HEADING "SID"                              FORMAT 99999
COLUMN inst_id                                 HEADING "I#"                               FORMAT 99
COLUMN session_handle                          HEADING "Session|Handle"                   FORMAT 99999999
COLUMN session_state                           HEADING "Session|State"                    FORMAT a10
COLUMN userid                                  HEADING "User"                             FORMAT a10
COLUMN total_transaction                       HEADING "Total|Tran"                       FORMAT 99999
COLUMN total_transaction_cpu_time              HEADING "Total|Tran|CPUTime"               FORMAT 999999999
COLUMN total_transaction_time                  HEADING "Total|Tran|Time"                  FORMAT 999999999

COLUMN logon_time   HEADING "Logon Time"   FORMAT a18
COLUMN username     HEADING "UserName"     FORMAT a20
COLUMN osuser       HEADING "OS User"      FORMAT a15 TRUNCATED
COLUMN MACHINE      HEADING "Machine"      FORMAT a20 TRUNCATED
COLUMN process      HEADING "Process"      FORMAT a11 
COLUMN program      HEADING "Program"      FORMAT a18 TRUNCATED
COLUMN event        HEADING "Event"        FORMAT a30 TRUNCATED
COLUMN last_call_et     HEADING "LastCall|(sec)" FORMAT 999,999        
--COLUMN last_call_et     HEADING "LastCall" FORMAT a12
COLUMN sql_child_number HEADING "SQL|Child|No"   FORMAT 99

SELECT l.owner || '.' || substr(l.table_name,4) aw_name
     , s.tablespace_name 
     , sum(s.bytes)/1024/1024 as mb
  FROM dba_lobs l
     , dba_segments s 
WHERE l.column_name = 'AWLOB' 
 AND l.segment_name = s.segment_name 
GROUP BY l.owner
       , l.table_name
       , s.tablespace_name 
ORDER BY l.owner
       , l.table_name
;


@@footer
