SELECT A.TABLESPACE_NAME,
       A.USE "USED (MB)",
       (B.TOTAL - A.USE) "FREE (MB)",
       B.TOTAL "TOTAL (MB)",
       round((B.TOTAL - A.USE) / B.TOTAL, 5) * 100 || '%' "PER_FREE"
  FROM (select TABLESPACE_NAME, sum(bytes) / (1024 * 1024) as USE
          from dba_segments
         GROUP BY TABLESPACE_NAME) A,
       (WITH TABLESPACE_TOTAL AS (SELECT tablespace_name,
                                         sum(MAXBYTES) / (1024 * 1024) TOTAL
                                    FROM DBA_DATA_FILES T
                                   WHERE T.AUTOEXTENSIBLE = 'YES'
                                   group by tablespace_name
                                  UNION ALL
                                  SELECT tablespace_name, sum(bytes) TOTAL
                                    FROM DBA_DATA_FILES T
                                   WHERE T.AUTOEXTENSIBLE = 'NO'
                                   group by tablespace_name)
         SELECT TABLESPACE_NAME, SUM(TOTAL) TOTAL
           FROM TABLESPACE_TOTAL
          GROUP BY TABLESPACE_NAME) B
          WHERE A.TABLESPACE_NAME = B.TABLESPACE_NAME

03-19 02:38