oracle11g - SQL Plus (Oracle 11) -
how can know largest table in database , owns it?
select segment_name table_name, sum(bytes) table_size user_segments segment_type='table' group segment_name
or should use (top
) or (rowcount
)
rownum won't here rownums calculated before ordering , want largest table.
with q ( select segment_name table_name, sum(bytes) table_size user_segments group segment_name ) select hlp.table_name, hlp.table_size (select q.*, dense_rank() over(order q.table_size desc) rn q) hlp hlp.rn = 1;
this trick. clause common table expression (cte), valid in context of following select under alias "q". wanted avoid multiple calls sum.
the dense_rank() function inside subquery in clause assings consecutive values of partition or order, in our case descending table size.
the subquery needed select first row.
regarding use of data dictionary tables haven't checked result.
Comments
Post a Comment