Press "Enter" to skip to content

oracle 查看表所占用的空间大小

1、查看表所占空间

SELECT   TABLESPACE_NAME,TO_CHAR(SUM(BYTES)/(1024*1024),'999G999D999')   CNT_MB  
  FROM   DBA_EXTENTS  
  WHERE   OWNER='&OWNER'   AND   SEGMENT_NAME='&TABLE_NAME'   AND   SEGMENT_TYPE   LIKE   'TABLE%'  
  GROUP   BY   TABLESPACE_NAME;

2、有两种含义的表大小。一种是分配给一个表的物理空间数量,而不管空间是否被使用。可以这样查询获得字节数:

select segment_name, bytes
from user_segments
where segment_type = 'TABLE';

或者

Select Segment_Name,Sum(bytes)/1024/1024 From User_Extents Group By Segment_Name;

另一种表实际使用的空间。这样查询:

analyze table emp compute statistics;
select num_rows * avg_row_len
from user_tables
where table_name = 'EMP';

查看每个表空间的大小:

Select Tablespace_Name,Sum(bytes)/1024/1024 From Dba_Segments Group By Tablespace_Name;

来源:http://luobeng.blogbus.com/logs/36329526.html

One Comment

  1. pba 2012-03-31

    小猪开始学Oracle了?

Leave a Reply to pba Cancel reply

Your email address will not be published. Required fields are marked *