查看表空间和表的使用率

1.   查看表空间使用率

--查询表空间的总容量

select tablespace_name,sum(bytes) /1024/1024 as MB from dba_data_files group by tablespace_name;

 

 

--查询表空间使用率

select total.tablespace_name,
       round(total.MB, 2) as Total_MB,
       round(total.MB - free.MB, 2) as Used_MB,
       round((1 - free.MB / total.MB) * 100, 2) || '%' as Used_Pct from
       (select tablespace_name,sum(bytes) / 1024 / 1024 as MB from dba_free_space group by tablespace_name) free,
       (select tablespace_name,sum(bytes) / 1024 / 1024 as MB from dba_data_files group by tablespace_name) total
       where free.tablespace_name = total.tablespace_name order by used_pct desc;

 

-- 对象类型:表   分区表   索引   分区索引共四种, 我们统计一下不同种类对象各多少size
 select segment_type,sum(bytes)/1024/1024 total_size from dba_segments where wner='CCARE' group by segment_type;

 

--SQL计算出某个用户下所有对象的大小

select owner,segment_name,segment_type,partition_name,bytes from dba_segments where wner='CCARE';

 

--我们经常使用的LEO1表空间使用情况已经perfect显示,现在我们需要统计的是LEO1表空间包含对象的大小,由于记录数较多,只把SQL语句写在这里了

 

 select o.object_name,o.object_type,o.owner,s.tablespace_name,s.segment_name,s.bytes from dba_objects o,dba_segments s where s.tablespace_name='LEO1' and o.owner=s.owner and o.owner='LEO1' and o.object_type=s.segment_type;

 
 
 
 
 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28588485/viewspace-755623/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/28588485/viewspace-755623/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值