-- -----------------------------------------------------------------------------------
-- File Name    : segment_stats.sql
-- Author       : DBA Learning Hub
-- Description  : Displays statistics for segments in th specified schema.
-- Requirements : Access to the V$ views.
-- Call Syntax  : @segment_stats
-- Last Modified: 15/07/2025
-- -----------------------------------------------------------------------------------
SELECT statistic#,
       name
FROM   v$segstat_name
ORDER BY statistic#;

ACCEPT l_schema char PROMPT 'Enter Schema: '
ACCEPT l_stat  NUMBER PROMPT 'Enter Statistic#: '
SET VERIFY OFF

SELECT object_name,
       object_type,
       value
FROM   v$segment_statistics 
WHERE  owner = UPPER('&l_schema')
AND    statistic# = &l_stat
ORDER BY value;
