We have a new partition table. I wanted to get the, each sub partition size in GB.
But, couldn’t find these anything related to partition table in dba_segments.
SELECT owner, segment_name, segment_type, partition_name,bytes/1024/1024/1024 "GB", tablespace_name
FROM DBA_SEGMENTS
WHERE SEGMENT_TYPE IN ('TABLE', 'TABLE PARTITION', 'TABLE SUBPARTITION',
'INDEX', 'INDEX PARTITION', 'INDEX SUBPARTITION')
AND SEGMENT_NAME LIKE 'TABLENAME'
ORDER BY bytes DESC;
Tried with above query, but I don’t see any of the records with my table name.
Please help, in locating my new partition table related size information for each sub partition.
5
Starting with 11.2, Oracle has a parameter called deferred_segment_creation
which defaults to TRUE
. When creating a new table or partitions, it creates the logical objects but does not yet allocate space in the tablespace, meaning there is no physical segment. dba_segments
displays physical segments only. You can still see your logical objects in dba_objects
, dba_indexes
, dba_tables
, dba_tab_partitions
, etc.. where a column named SEGMENT_CREATED
will say 'NO'
, telling you that it hasn’t created a physical segment yet for the object.
As soon as you insert a single row, it now must create a physical segment and allocate space in the tablespace. This is when rows will show up in dba_segments
.
So, to see your table, start with the logical object views and outer join back on dba_segments
to get size, interpreting a lack of any such row to mean no segment and therefore size 0 bytes. You will also need to modify your query to show the indexes separately, as that requires mapping your table name to the index names before you can find them in dba_segments
:
SELECT sp.table_name,sp.partition_name,sp.subpartition_name,s.segment_type,NVL(s.bytes,0) bytes
FROM dba_tab_subpartitions sp,
dba_segments s
WHERE sp.table_name = 'MYTABLENAME'
AND sp.table_owner = s.owner(+)
AND sp.table_name = s.segment_name(+)
AND sp.subpartition_name = s.partition_name(+)
UNION ALL
SELECT i.index_name,sp.partition_name,sp.subpartition_name,s.segment_type,NVL(s.bytes,0) bytes
FROM dba_indexes i,
dba_ind_subpartitions sp,
dba_segments s
WHERE i.table_name = 'MYTABLENAME'
AND i.owner = sp.index_owner(+)
AND i.index_name = sp.index_name(+)
AND sp.index_owner = s.owner(+)
AND sp.index_name = s.segment_name(+)
AND sp.subpartition_name = s.partition_name(+)
2