SELECT
t.owner,
t.table_name,
s.tablespace_name,
ROUND(s.bytes / 1024 / 1024, 2) AS size_mb,
t.num_rows,
t.last_analyzed,
MAX(hs.end_time) AS last_access_time
FROM dba_tables t
JOIN dba_segments s
ON t.owner = s.owner AND t.table_name = s.segment_name AND s.segment_type = 'TABLE'
LEFT JOIN dba_hist_seg_stat_obj hso
ON t.owner = hso.owner AND t.table_name = hso.object_name
LEFT JOIN dba_hist_seg_stat hs
ON hso.obj# = hs.obj#
WHERE t.owner = 'YOUR_SCHEMA'
AND REGEXP_LIKE(t.table_name,
'(_BAK$|_TMP$|_COPY$|_OLD$|_TEST$|_ARCH$|_STAGE$|_SNAP$|_DUP$|^TMP_|^STG_|^BK_|^OLD_|^NEW_|^TEST_)', 'i')
GROUP BY t.owner, t.table_name, s.tablespace_name, s.bytes, t.num_rows, t.last_analyzed
ORDER BY size_mb DESC;





0 comments:
Post a Comment