代码改变世界

Oracle:查看表空间使用情况.

2011-10-14 16:59  Tracy.  阅读(348)  评论(0编辑  收藏  举报

//* Formatted on 10/14/2011 4:56:17 PM (QP5 v5.163.1008.3004) */
  SELECT a.tablespace_name,
         ROUND (a.total_size, 1) "total(M)",
         ROUND (a.total_size) - ROUND (NVL (b.free_size, 0), 1) "used(M)",
         ROUND (NVL (b.free_size, 0), 1) "free(M)",
         ROUND (NVL (b.free_size, 0) / total_size * 100, 1) "free rate(%)"
    FROM (  SELECT tablespace_name, SUM (bytes) / 1024 / 1024 total_size
              FROM dba_data_files
          GROUP BY tablespace_name) a,
         (  SELECT tablespace_name, SUM (bytes) / 1024 / 1024 free_size
              FROM dba_free_space
          GROUP BY tablespace_name) b
   WHERE a.tablespace_name = b.tablespace_name(+)
ORDER BY "free rate(%)";