oracle查表占的物理空间,查询Oracle表实际物理使用大小
Oracle中有兩種含義的表大小
一種是分配給一個表的物理空間數量,而不管空間是否被使用??梢赃@樣查詢獲得字節數:
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;
效果如下:【這個查詢速度慢】
上兩圖結果所示,查詢均為10896M分配給表的大小
下圖查詢出該表當前占用的實際空間大小
另一種表實際使用的空間。這樣查詢:
analyze table emp compute statistics;
select num_rows * avg_row_len
from user_tables
where table_name = EMP;--EMP為表名(表名大寫查詢)
效果如下:
該表實際占用空間大小為9506M左右。
附:
查看每個表空間的大小
Select Tablespace_Name,Sum(bytes)/1024/1024 from Dba_Segments Group By Tablespace_Name
1.查看剩余表空間大小
SELECT tablespace_name 表空間,sum(blocks*8192/1000000) 剩余空間M from dba_free_space GROUP BY tablespace_name;
2.檢查系統中所有表空間總體空間
select b.name,sum(a.bytes/1000000)總空間 from v$datafile a,v$tablespace b where a.ts#=b.ts# group by b.name;
3.查詢整個數據庫剩余和使用的表空間大小使用情況:
select df.tablespace_name "表空間名",totalspace "總空間M",freespace "剩余空間M",round((1-freespace/totalspace)*100,2) "使用率%"
from
(select tablespace_name,round(sum(bytes)/1024/1024) totalspace
from dba_data_files
group by tablespace_name) df,
(select tablespace_name,round(sum(bytes)/1024/1024) freespace
from dba_free_space
group by tablespace_name) fs
where df.tablespace_name=fs.tablespace_name;
效果如下:
總結
以上是生活随笔為你收集整理的oracle查表占的物理空间,查询Oracle表实际物理使用大小的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: html打印边距影响内容大小,关于web
- 下一篇: session会话拦截ajax,sess