/* ************************************************ */
/*                                                  */
/* fnctn:   Table Utilization                       */
/*                                                  */
/* name:    @c:\oracle\sql\tssuser.sql              */
/* date:    12-MAY-95                               */
/* creator: Rick Kupcunas (Oracle)                  */
/*                                                  */
/* ************************************************ */

set termout       off
set newpage       0
set pagesize      60
set linesize      75
set feedback      off
set trimout       on
set verify        on
set wrap          on
set termout       off
set echo          off

spool tssumuser.rslt
ttitle center 'TSSUSER - Database Tablespace per User Summary' skip 1 -
left "PAGE:" sql.pno format 999 right CWS_DATE skip 2

col username        format a20            heading 'Username'        justify c
col tablespace_name format a20            heading 'Tablespace Name' justify c
col mquota          format a12            heading 'MB Quota'        justify c
col mbytes          format 999,999,990.99 heading 'MB Used'         justify c

break on username

select
  username,
  tablespace_name,
  decode(greatest(max_bytes, -1), -1, 'Unrestricted',
         to_char(max_bytes/1048576, '999,999,990')) mquota,
  bytes/1048576     mbytes
from
  sys.dba_ts_quotas
where
  (max_bytes != 0) or
  (bytes     != 0)
order by
  1,3;

clear col
clear bre
spool off
exit
