When working with Oracle databases, monitoring table storage consumption is crucial for database administrators and developers. Oracle stores table data in segments, which consist of extents allocated in tablespaces. The total space used includes:
- Actual data storage
- Index space
- LOB segments
- Partition storage (if applicable)
Oracle Enterprise Manager provides a graphical interface to check table storage:
- Navigate to Schema → Tables
- Search for your target table
- Click the table name to view details
- Check the "Segments" tab for storage information
The interface displays allocated space, used space, and wasted space in both MB and percentage formats.
For precise measurements, use these SQL queries:
-- Basic table size in MB
SELECT
segment_name AS table_name,
segment_type,
bytes/1024/1024 AS size_mb
FROM
user_segments
WHERE
segment_name = 'YOUR_TABLE_NAME';
For detailed breakdown including indexes and partitions:
SELECT
s.segment_name,
s.segment_type,
s.bytes/1024/1024 AS size_mb,
s.blocks,
s.extents
FROM
dba_segments s
WHERE
s.owner = 'SCHEMA_OWNER'
AND s.segment_name IN (
SELECT table_name FROM dba_tables WHERE table_name = 'YOUR_TABLE_NAME'
UNION
SELECT index_name FROM dba_indexes WHERE table_name = 'YOUR_TABLE_NAME'
UNION
SELECT partition_name FROM dba_tab_partitions WHERE table_name = 'YOUR_TABLE_NAME'
)
ORDER BY
s.bytes DESC;
To see how space is distributed across tablespaces:
SELECT
tablespace_name,
SUM(bytes)/1024/1024 AS total_mb
FROM
dba_segments
WHERE
segment_name = 'YOUR_TABLE_NAME'
GROUP BY
tablespace_name;
For monitoring growth patterns, query DBA_HIST_SEG_STAT:
SELECT
h.snap_id,
TO_CHAR(s.begin_interval_time, 'DD-MON-YYYY HH24:MI') AS snap_time,
h.space_used_total/1024/1024 AS space_used_mb
FROM
dba_hist_seg_stat h
JOIN
dba_hist_snapshot s ON h.snap_id = s.snap_id
WHERE
h.obj# = (SELECT object_id FROM dba_objects
WHERE object_name = 'YOUR_TABLE_NAME' AND owner = 'SCHEMA_OWNER')
ORDER BY
h.snap_id;
Understanding a table's storage footprint is crucial for database administrators and developers working on performance tuning and capacity planning. Oracle provides multiple ways to check table size, including both Enterprise Manager (OEM) and SQL queries.
The Oracle Enterprise Manager interface provides a visual way to check table storage:
- Log in to Oracle Enterprise Manager
- Navigate to Schema → Tables
- Search for your target table
- Click on the table name to view details
- Check the "Storage" tab for size information
For more detailed analysis, these SQL queries provide comprehensive size information:
-- Basic table size in MB
SELECT segment_name AS table_name,
segment_type,
ROUND(bytes/1024/1024,2) AS size_mb
FROM user_segments
WHERE segment_name = 'YOUR_TABLE_NAME';
-- More detailed view including indexes
SELECT
t.table_name,
ROUND(SUM(s.bytes)/1024/1024,2) AS total_size_mb,
ROUND(SUM(CASE WHEN s.segment_type = 'TABLE' THEN s.bytes ELSE 0 END)/1024/1024,2) AS table_size_mb,
ROUND(SUM(CASE WHEN s.segment_type = 'INDEX' THEN s.bytes ELSE 0 END)/1024/1024,2) AS index_size_mb
FROM
user_tables t
JOIN
user_segments s ON s.segment_name = t.table_name
OR s.segment_name IN (SELECT index_name FROM user_indexes WHERE table_name = t.table_name)
WHERE
t.table_name = 'YOUR_TABLE_NAME'
GROUP BY
t.table_name;
The queries return:
- Table_name: Name of your table
- Size_mb: Total space occupied in megabytes
- Segment_type: Distinguishes between table space and index space
For partitioned tables or more granular analysis:
-- Size by partition
SELECT partition_name,
ROUND(bytes/1024/1024,2) AS partition_size_mb
FROM user_segments
WHERE segment_name = 'YOUR_TABLE_NAME'
ORDER BY partition_name;
-- Space usage by tablespace
SELECT tablespace_name,
ROUND(SUM(bytes)/1024/1024,2) AS total_mb
FROM user_segments
WHERE segment_name = 'YOUR_TABLE_NAME'
GROUP BY tablespace_name;
For regular monitoring, consider creating a view:
CREATE OR REPLACE VIEW table_size_monitor AS
SELECT
t.table_name,
ROUND(SUM(s.bytes)/1024/1024,2) AS size_mb,
SYSDATE AS check_date
FROM
user_tables t
JOIN
user_segments s ON s.segment_name = t.table_name
GROUP BY
t.table_name;