• 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

  • 相关阅读:
    大同世界的Java 和.NET 开发
    关于Memcached 你了解多少?
    C#二进制与字符串之间的相互转换
    Nopcommerce主要用到的技术及特点
    小程序之路
    .NET方面的框架的整理和总结
    如何将FastReportOnlineDesign 灵活的应用到C/S B/S 程序当中?
    WebApi 的CRUD 的方法的应用
    关于EF 通用增删改查的封装
    基于Json序列化和反序列化通用的封装
  • 原文地址:https://www.cnblogs.com/tianlesoftware/p/3609280.html
Copyright © 2020-2023  润新知