查询Oracle表实际物理使用大小

Oracle中有两种含义的表大小
一种是分配给一个表的物理空间数量,而不管空间是否被使用。可以这样查询获得字节数:
select segment_name, bytes
from user_segments
where segment_type = TABLE;

或:          

select sum(bytes)/(1024*1024) as "size(M)" from user_segments
  where segment_name='T_ORG_TEMPLATE';

效果如下:


或者
   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;
效果如下:
 



转自:http://www.2cto.com/database/201107/95313.html


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值