Sunday, 25 May 2025

Filled under:

 SET LINES 200

COLUMN owner FORMAT A20

COLUMN table_name FORMAT A30

COLUMN tablespace_name FORMAT A20

COLUMN total_size_gb FORMAT 999,999.99


-- Get total table size (including base + LOB + overflow segments)

SELECT s.owner,

       s.segment_name AS table_name,

       s.tablespace_name,

       ROUND(SUM(s.bytes) / (1024 * 1024 * 1024), 2) AS total_size_gb

FROM dba_segments s

WHERE s.segment_type IN ('TABLE', 'TABLE PARTITION', 'LOBSEGMENT', 'LOB PARTITION')

  AND s.tablespace_name = 'TABLESPACE_A'

GROUP BY s.owner, s.segment_name, s.tablespace_name

HAVING SUM(s.bytes) > 0

ORDER BY total_size_gb DESC;


0 comments:

Post a Comment