标题: ora工具介绍 [打印本页] 作者: zhouwei1990 时间: 2017-7-7 11:20 标题: ora工具介绍 相信大家工作中会遇到很多要写SQL进行维护的情况,比如查询表空间使用率情况:
需要dba_free_space与dba_data_files进行关联查询处理:
select b.tablespace_name,round(sum(b.bytes)/1024/1024,0) sum_MB, round(sum(nvl(a.bytes,0))/1024/1024,0) free_MB,
round((sum(b.bytes)-sum(nvl(a.bytes,0)))/sum(b.bytes),4)*100 use_precent
from (select tablespace_name,file_id,sum(bytes) bytes from dba_free_space group by tablespace_name,file_id ) a,
dba_data_files b
where a.file_id(+)=b.file_id and a.tablespace_name(+)=b.tablespace_name
group by b.tablespace_name
order by 4 desc;