Get tables in tablespace by perentage

Last updated:

Warning: Review and test in a non-production environment before running.

Back to results

SELECT seg.SEGMENT_NAME,
       ROUND((SUM(bytes) / total.total_bytes) * 100, 2) AS percent_usage
  FROM dba_segments seg JOIN 
        (SELECT SUM(bytes) AS total_bytes 
         FROM dba_segments 
         WHERE tablespace_name = 'TABLE SPACE NAME') total
    ON 1=1
 WHERE seg.tablespace_name = 'TABLE SPACE NAME'
   AND seg.segment_type = 'TABLE'
 GROUP BY SEGMENT_NAME, total.total_bytes
 ORDER BY percent_usage DESC;