ITPub博客

首页 > Linux操作系统 > Linux操作系统 > oracle 表空间使用百分比的sql

oracle 表空间使用百分比的sql

原创 Linux操作系统 作者:perfychi 时间:2012-10-31 11:45:27 0 删除 编辑
sql代码:

set linesize 200
with a as ( select tablespace_name, sum(bytes)/1024/1024 total  from dba_data_files group by tablespace_name),
     b as ( select tablespace_name, sum(bytes)/1024/1024  free   from dba_free_space group by tablespace_name)
select a.tablespace_name, a.total as "TOTAL(M)", b.free as "FREE(M)",round((1-b.free/a.total) * 100, 2) as "USED(%)"
from a, b 
where a.tablespace_name=b.tablespace_name;
 
 
或者:
set linesize 200z
select a.tablespace_name, a.total  as "TOTAL(M)", b.free  as "FREE(M)", (1-b.free/a.total)* 100 as "USED(%)"
from
(select tablespace_name, sum(bytes)/1024/1024  total from dba_data_files
 group by tablespace_name) a
,
(select tablespace_name, sum(bytes)/1024/1024  free from dba_free_space
 group by tablespace_name) b
where a.tablespace_name=b.tablespace_name



测试结果:

2012-10-31_115344.jpg

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

上一篇: crontab试验
下一篇: oracle 查权sql
请登录后发表评论 登录
全部评论

注册时间:2012-06-06

  • 博文量
    484
  • 访问量
    2976213