欢迎光临
我们一直在努力

查询DB表实际大小

1.查询DB表实际大小(保证clob/blob/nclob lob大字段)

 select round(sum(bytes/1024/1024/1024),2) ||'G' from dba_segments where owner='用户' 
 and segment_name ='表' OR segment_name IN (select SEGMENT_NAME from dba_LOBS where TABLE_NAME='表' and owner='用户');

如果不是dba用户可以用user_segments & user_lobs 且不需要owner.

2. 查询表里LOB大字段

   select round(sum(b.BYTES/1024/1024),2) ||'M' from dba_lobs a, dba_segments b  
 where a.segment_name = b.segment_name  and a.owner = '用户(大写)' and a.table_name = '表(大写)' ;

3.查询表大小不带LOB大字段

select round(sum(bytes/1024/1024/1024),2) ||'G' from user_segments where segment_name ='表';

4.表数据被删除

a. 若表的数据被truncate,上述方法查到的数据会立即变化

b. 若表的数据被delete,则需要对表进行收缩,上述查询才会变化;

 alter table 表名 enable row movement;
 alter table 表名 shrink space;

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。