查詢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;


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章