• Oracle 查看表空间使用率 SQL 脚本


    SQL 语句:

    /* Formatted on 2012/5/31 14:51:13 (QP5 v5.185.11230.41888) */
    SELECT D.TABLESPACE_NAME,
           SPACE || 'M' "SUM_SPACE(M)",
           BLOCKS "SUM_BLOCKS",
           SPACE - NVL (FREE_SPACE, 0) || 'M' "USED_SPACE(M)",
           ROUND ( (1 - NVL (FREE_SPACE, 0) / SPACE) * 100, 2) || '%'
              "USED_RATE(%)",
           FREE_SPACE || 'M' "FREE_SPACE(M)"
      FROM (  SELECT TABLESPACE_NAME,
                     ROUND (SUM (BYTES) / (1024 * 1024), 2) SPACE,
                     SUM (BLOCKS) BLOCKS
                FROM DBA_DATA_FILES
            GROUP BY TABLESPACE_NAME) D,
           (  SELECT TABLESPACE_NAME,
                     ROUND (SUM (BYTES) / (1024 * 1024), 2) FREE_SPACE
                FROM DBA_FREE_SPACE
            GROUP BY TABLESPACE_NAME) F
     WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME(+)
    UNION ALL                                                           --如果有临时表空间
    SELECT D.TABLESPACE_NAME,
           SPACE || 'M' "SUM_SPACE(M)",
           BLOCKS SUM_BLOCKS,
           USED_SPACE || 'M' "USED_SPACE(M)",
           ROUND (NVL (USED_SPACE, 0) / SPACE * 100, 2) || '%' "USED_RATE(%)",
           NVL (FREE_SPACE, 0) || 'M' "FREE_SPACE(M)"
      FROM (  SELECT TABLESPACE_NAME,
                     ROUND (SUM (BYTES) / (1024 * 1024), 2) SPACE,
                     SUM (BLOCKS) BLOCKS
                FROM DBA_TEMP_FILES
            GROUP BY TABLESPACE_NAME) D,
           (  SELECT TABLESPACE_NAME,
                     ROUND (SUM (BYTES_USED) / (1024 * 1024), 2) USED_SPACE,
                     ROUND (SUM (BYTES_FREE) / (1024 * 1024), 2) FREE_SPACE
                FROM V$TEMP_SPACE_HEADER
            GROUP BY TABLESPACE_NAME) F
     WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME(+)
    ORDER BY 1;


    效果如下:

    -------------------------------------------------------------------------------------------------------

    版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!

    Skype:            tianlesoftware

    QQ:                 tianlesoftware@gmail.com

    Email:             tianlesoftware@gmail.com

    Blog:   http://www.tianlesoftware.com

    Weibo:            http://weibo.com/tianlesoftware

    Twitter: http://twitter.com/tianlesoftware

    Facebook: http://www.facebook.com/tianlesoftware

    Linkedin: http://cn.linkedin.com/in/tianlesoftware

    -------加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请----

    DBA1 群:62697716(满);   DBA2 群:62697977(满)  DBA3 群:62697850(满)  

    DBA 超级群:63306533(满);  DBA4 群:83829929   DBA5群: 142216823

    DBA6 群:158654907    DBA7 群:172855474   DBA总群:104207940

  • 相关阅读:
    redis、memcache、mongoDB有哪些区别(转载)
    初识spring与quartz整合实现定时任务
    使用CXF与Spring集成实现RESTFul WebService
    Linux top
    JS操作Radio与Select
    初识Redis
    JVM基础学习
    自动装配【Spring autowire】
    包含中文的字符串中截取前N个字符
    EF中Json序列化对象时检测到循环引用的解决办法
  • 原文地址:https://www.cnblogs.com/tianlesoftware/p/3609279.html
Copyright © 2020-2023  润新知