监控表空间使用率

临时表空间:

select *
  from (select a.tablespace_name, sum(a.bytes / 1024 / 1024) allocated_mb
          from dba_temp_files a
         where a.tablespace_name = upper('&&temp_tsname')
         group by a.tablespace_name) x,
       (select sum(b.bytes_used / 1024 / 1024) used_mb,
               sum(b.bytes_free / 1024 / 1024) free_mb
          from v$temp_space_header b
         where b.tablespace_name = upper('&&temp_tsname')
         group by b.tablespace_name);



永久表空间:

select a.tablespace_name "表空间名",
       round(total / 1024 / 1024, 2) 表空间大小,
       round(free / 1024 / 1024, 2) 表空间剩余大小,
       round((total - free) / 1024 / 1024, 2) 表空间使用大小,
       round((total - free) / total, 4) * 100 "使用率 %"
  from (select tablespace_name, sum(bytes) free
          from dba_free_space
         group by tablespace_name) a,
       (select tablespace_name, sum(bytes) total
          from dba_data_files
         group by tablespace_name) b
 where a.tablespace_name = b.tablespace_name;


你可能感兴趣的:(监控表空间使用率)