码迷,mamicode.com
首页 > 数据库 > 详细

Oracle查看表空间使用率

时间:2015-05-30 01:46:22      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:

SELECT DBF.TABLESPACE_NAME,
       DBF.TOTALSPACE "总量(M)",
       DBF.TOTALBLOCKS AS 总块数,
       DBF.TOTALSPACE-DFS.FREESPACE "使用量(M)",
       DBF.TOTALBLOCKS-DFS.FREEBLOCKS AS 使用块数,      
       DFS.FREESPACE "剩余总量(M)",
       DFS.FREEBLOCKS "剩余块数",
       (DFS.FREESPACE / DBF.TOTALSPACE) * 100 "空闲比例"
  FROM (SELECT T.TABLESPACE_NAME,
               SUM(T.BYTES) / 1024 / 1024 TOTALSPACE,
               SUM(T.BLOCKS) TOTALBLOCKS
          FROM DBA_DATA_FILES T
         GROUP BY T.TABLESPACE_NAME) DBF,
       (SELECT TT.TABLESPACE_NAME,
               SUM(TT.BYTES) / 1024 / 1024 FREESPACE,
               SUM(TT.BLOCKS) FREEBLOCKS
          FROM DBA_FREE_SPACE TT
         GROUP BY TT.TABLESPACE_NAME) DFS
 WHERE TRIM(DBF.TABLESPACE_NAME) = TRIM(DFS.TABLESPACE_NAME);
 
SELECT A.TABLESPACE_NAME,
       A.BYTES/ 1024 / 1024 TOTAL,
       B.BYTES/ 1024 / 1024 USED,
       C.BYTES/ 1024 / 1024 FREE,
       (B.BYTES * 100) / A.BYTES "% USED ",
       (C.BYTES * 100) / A.BYTES "% FREE "
  FROM SYS.SM$TS_AVAIL A, SYS.SM$TS_USED B, SYS.SM$TS_FREE C
 WHERE A.TABLESPACE_NAME = B.TABLESPACE_NAME
   AND A.TABLESPACE_NAME = C.TABLESPACE_NAME;
 

SELECT Total.name "Tablespace Name",
       Free_space,
       (total_space - Free_space) Used_space,
       total_space
  FROM (select tablespace_name, sum(bytes / 1024 / 1024) Free_Space
          from sys.dba_free_space
         group by tablespace_name) Free,

Oracle查看表空间使用率

标签:

原文地址:http://www.cnblogs.com/longjshz/p/4539693.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!