1.查询分配给一个表的空间大小
使用视图user_segments查询:
SQL> select segment_name,sum(bytes/1024) kb from user_segments where segment_name=upper('emp') group by segment_name;
SEGMENT_NAME
--------------------------------------------------------------------------------
KB
----------
EMP
64
使用视图user_extents查询:
SQL> select segment_name,sum(bytes/1024) kb from user_extents where segment_name=upper('emp') group by segment_name;
SEGMENT_NAME
--------------------------------------------------------------------------------
KB
----------
EMP
64
2.查询表实际使用的空间:
SQL> analyze table emp compute statistics;
Table analyzed.
SQL> select num_rows*avg_row_len from user_tables where table_name='EMP';
NUM_ROWS*AVG_ROW_LEN
--------------------
585
SQL> select segment_name,sum(bytes)/1024 KB from user_segments
2 where segment_name='EMP' group by segment_name;
SEGMENT_NAME
--------------------------------------------------------------------------------
KB
----------
EMP
64