***********************************************************************
* Description: SQL for querying temp tablespace utilization by session
* Compatiablity: RDBMS 11g, 12c
* Date: 04:08 PM EST, 04/01/2017
***********************************************************************


<1> Checking temp tablespace usage by session: -- V$SORT_USAGE can be replacable by view V$TEMPSEG_USAGE
     |
     |__ SQL> select 
                 srt.tablespace, 
                 srt.segfile#, 
                 srt.segblk#, 
                 srt.blocks, 
                 a.sid, 
                 a.serial#, 
                 a.username, 
                 a.osuser, 
                 a.status 
              from 
                 v$session a,
                 v$sort_usage srt 
              where 
                 a.saddr = srt.session_addr 
              order by 
                 srt.tablespace, srt.segfile#, srt.segblk#, 
                 srt.blocks;