淘先锋技术网

首页 1 2 3 4 5 6 7

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

转载于:https://www.cnblogs.com/sisier/p/4795113.html