Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3692988
  • 博文数量: 715
  • 博客积分: 1860
  • 博客等级: 上尉
  • 技术积分: 7745
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-07 08:51
个人简介

偶尔有空上来看看

文章分类

全部博文(715)

文章存档

2023年(75)

2022年(134)

2021年(238)

2020年(115)

2019年(11)

2018年(9)

2017年(9)

2016年(17)

2015年(7)

2014年(4)

2013年(1)

2012年(11)

2011年(27)

2010年(35)

2009年(11)

2008年(11)

分类: 数据库开发技术

2023-11-25 14:01:39


  1. set lineshow off
  2.   SELECT TABLESPACE_NAME,
  3.          TS_TYPE,
  4.          TRUNC(TS_CURR_TOTAL)AS CUR_SIZE_MB,
  5.          TRUNC(TS_CURR_TOTAL-USED) AS CURR_FREE_MB,
  6.          TRUNC(USED) AS USED_MB,
  7.          TRUNC(PCT_CURR_USED) AS CURR_USED_PCT,
  8.          DECODE(STATUS,
  9.                          0, 'ONLINE',
  10.                          'OFFLINE') AS STATUS,
  11.          TRUNC(TS_TOTAL) AS MAX_SIZE_MB,
  12.          TRUNC(TS_TOTAL-USED) AS FREE_MB,
  13.          TRUNC(PCT_USED) AS USED_PCT
  14.     FROM ( SELECT DF.NAME AS TABLESPACE_NAME,
  15.                    'PERMANENT' AS TS_TYPE,
  16.                    STATUS$ AS STATUS,
  17.                    MAX_SIZE AS TS_TOTAL,
  18.                    CURR_MAX_SIZE AS TS_CURR_TOTAL,
  19.                    DECODE((MAX_SIZE - USED_SIZE_T),
  20.                                     NULL, 0,
  21.                                     MAX_SIZE - USED_SIZE_T) AS FREE,
  22.                    DECODE((CURR_MAX_SIZE - USED_SIZE_T),
  23.                                     NULL, 0,
  24.                                     CURR_MAX_SIZE - USED_SIZE_T) AS CURR_FREE,
  25.                    DECODE(USED_SIZE_T,
  26.                                     NULL, 0,
  27.                                     USED_SIZE_T) AS USED,
  28.                    DECODE(USED_SIZE_T,
  29.                                     NULL, 0,
  30.                                     ROUND(CAST(USED_SIZE_T / CURR_MAX_SIZE AS DECIMAL) * 100)) AS PCT_CURR_USED,
  31.                    DECODE(USED_SIZE_T,
  32.                                     NULL, 0,
  33.                                     ROUND(CAST(USED_SIZE_T / MAX_SIZE AS DECIMAL) * 100)) AS PCT_USED
  34.               FROM (SELECT A.NAME,
  35.                             A.ID,
  36.                             A.STATUS$,
  37.                             SUM(CAST(B.TOTAL_SIZE - B.FREE_SIZE AS DECIMAL) * PAGE() / 1024 / 1024) AS USED_SIZE_P,
  38.                             SUM(CASE AUTO_EXTEND WHEN 0 THEN CAST(B.TOTAL_SIZE AS DECIMAL) * PAGE() / 1024 / 1024 WHEN 1 THEN B.MAX_SIZE END) AS MAX_SIZE,
  39.                             SUM(CAST(B.TOTAL_SIZE AS DECIMAL) * PAGE() / 1024 / 1024) AS CURR_MAX_SIZE
  40.                        FROM V$DATAFILE B,
  41.                             V$TABLESPACE A
  42.                       WHERE B.GROUP_ID = A.ID AND A.NAME NOT IN ('TEMP',
  43.                                                                  'ROLL')
  44.                    GROUP BY A.NAME,
  45.                             A.ID,
  46.                             A.STATUS$) DF
  47.          LEFT JOIN (SELECT TS_ID,
  48.                             SUM(N_FULL_EXTENT + N_FREE_EXTENT + N_FRAG_EXTENT) * SF_GET_EXTENT_SIZE() * PAGE() / 1024 / 1024 AS USED_SIZE_T
  49.                        FROM V$SEGMENT_INFOS
  50.                    GROUP BY TS_ID) SEG
  51.                 ON SEG.TS_ID = DF.ID
  52.          UNION ALL
  53.          SELECT TABLESPACE_NAME,
  54.                 'UNDO' AS TS_TYPE,
  55.                 STATUS,
  56.                 TS_TOTAL,
  57.                 TOTAL AS TS_CURR_TOTAL,
  58.                 FREE,
  59.                 FREE AS CURR_FREE,
  60.                 (TOTAL - FREE) AS USED,
  61.                 ROUND(CAST((TOTAL - FREE) AS DECIMAL) * 100 / TOTAL) PCT_CURR_USED,
  62.                 ROUND(CAST((TOTAL - FREE) AS DECIMAL) * 100 / TS_TOTAL) PCT_USED
  63.            FROM (SELECT T.NAME TABLESPACE_NAME,
  64.                          T.STATUS$ STATUS,
  65.                          SUM(CAST(FREE_SIZE AS DECIMAL) * PAGE() / 1024 / 1024) AS FREE,
  66.                          SUM(CAST(D.TOTAL_SIZE AS DECIMAL) * PAGE() / 1024 / 1024) AS TOTAL,
  67.                          SUM(CASE AUTO_EXTEND WHEN 0 THEN CAST(D.TOTAL_SIZE AS DECIMAL) * PAGE() / 1024 / 1024 WHEN 1 THEN D.MAX_SIZE END) AS TS_TOTAL
  68.                     FROM V$TABLESPACE T,
  69.                          V$DATAFILE D
  70.                    WHERE T.ID = D.GROUP_ID AND T.NAME IN ('ROLL')
  71.                 GROUP BY T.NAME,
  72.                          T.STATUS$)
  73.          UNION ALL
  74.          SELECT TABLESPACE_NAME,
  75.                 'TEMPORARY' AS TS_TYPE,
  76.                 STATUS,
  77.                 TS_TOTAL,
  78.                 TOTAL AS TS_CURR_TOTAL,
  79.                 FREE,
  80.                 FREE AS CURR_FREE,
  81.                 (TOTAL - FREE) USED,
  82.                 ROUND(CAST((TOTAL - FREE) AS DECIMAL) * 100 / TOTAL) PCT_CURR_USED,
  83.                 ROUND(CAST((TOTAL - FREE) AS DECIMAL) * 100 / TS_TOTAL) PCT_USED
  84.            FROM (SELECT T.NAME TABLESPACE_NAME,
  85.                         T.STATUS$ STATUS,
  86.                         CAST(FREE_SIZE AS DECIMAL) * PAGE() / 1024 / 1024 AS FREE,
  87.                         CAST(D.TOTAL_SIZE AS DECIMAL) * PAGE() / 1024 / 1024 AS TOTAL,
  88.                         CASE (SELECT SYS_VALUE
  89.                                  FROM V$PARAMETER
  90.                                 WHERE NAME = 'TEMP_SPACE_LIMIT') WHEN 0 THEN 99999999 ELSE (SELECT SYS_VALUE
  91.                                                                                                FROM V$PARAMETER
  92.                                                                                               WHERE NAME = 'TEMP_SPACE_LIMIT') END AS TS_TOTAL
  93.                    FROM V$TABLESPACE T,
  94.                         V$DATAFILE D
  95.                   WHERE T.ID = D.GROUP_ID AND T.NAME IN ('TEMP')) )
  96. ORDER BY TS_TYPE,
  97.          PCT_CURR_USED DESC;

阅读(325) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~