记录下查询表空间使用率信息的语句

来源:互联网 发布:win32 编程 编辑:程序博客网 时间:2024/06/06 01:19
SELECT "TABLESPACE_NAME",
       "PCT_USED" as "PCT_USED(%)",
       "ALLOCATED" as "ALLOCATED(mb)",
       "USED" as "USED(mb)",
       "FREE" as "FREE(%)",
       "DATAFILES"
  FROM (SELECT a.tablespace_name,              
               ROUND(((c.bytes - nvl(b.bytes, 0)) / c.bytes) * 100, 2) PCT_USED,
               c.bytes / 1024 / 1024 allocated,
               round(c.bytes / 1024 / 1024 - nvl(b.bytes, 0) / 1024 / 1024,
                     2) used,
               round(nvl(b.bytes, 0) / 1024 / 1024, 2) free,
               c.datafiles
          FROM dba_tablespaces a,
               (SELECT tablespace_name, SUM(bytes) bytes
                  FROM dba_free_space
                 GROUP BY tablespace_name) b,
               (select count(1) datafiles, SUM(bytes) bytes, tablespace_name
                  from dba_data_files
                 GROUP BY tablespace_name) c
         WHERE b.tablespace_name(+) = a.tablespace_name
           AND c.tablespace_name(+) = a.tablespace_name
         ORDER BY nvl(((c.bytes - nvl(b.bytes, 0)) / c.bytes), 0) DESC)
0 0
原创粉丝点击