码迷,mamicode.com
首页 > 数据库 > 详细

oracle表空间使用率查询

时间:2015-09-09 17:19:47      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

sqlplus -s / as sysdba<<EOF
set trimspool on
set linesize 10000
set pagesize 50000
set heading on
set term off
set heading on
set feedback off;
set newp none;
set echo off
set markup html on
spool on
spool xj.xls
--表空间使用率查询:

select t.tablespace_name,t.total,f.free,(t.total - f.free) / t.total * 100 used_percent
from
(select a.tablespace_name,sum(a.bytes/1024/1024) total
from dba_data_files a
group by a.tablespace_name
) t,
(select b.tablespace_name,sum(b.bytes/1024/1024) free
from dba_free_space b
group by b.tablespace_name
) f
where t.tablespace_name = f.tablespace_name
;

--临时表空间使用率查询(gv_$temp_space_header视图需要使用sys用户查看)

select a.tablespace_name,b.total,a.used,a.used / b.total * 100 used_percent,
       a.free,a.free / b.total * 100 free_percent
from
(select tablespace_name,sum(bytes_used/1024/1024) used,sum(bytes_free/1024/1024) free
from gv_\$temp_space_header
group by tablespace_name
) a,
(select tablespace_name,sum(bytes/1024/1024) total
from dba_temp_files
group by tablespace_name
) b
where a.tablespace_name = b.tablespace_name
;
spool off
EOF

oracle表空间使用率查询

标签:

原文地址:http://www.cnblogs.com/sisier/p/4795113.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!