Oracle DB で表領域の使用率などを見る

Oracle DB で表領域の使用率などを見るには、以下のような SELECT 文を作れば良い。

SELECT
    d.TABLESPACE_NAME,
    BYTES                             AS "全体量 [MB]",
    ROUND(BYTES - FREE)               AS "使用量 [MB]",
    FREE                              AS "空容量 [MB]",
    ROUND((1 - (FREE / BYTES)) * 100) AS "使用率 [%]"
FROM
    (
        SELECT
            TABLESPACE_NAME,
            ROUND(SUM(BYTES) / (1024 * 1024)) AS BYTES
        FROM
            DBA_DATA_FILES
        GROUP BY
            TABLESPACE_NAME
    ) d
    LEFT JOIN (
        SELECT
            TABLESPACE_NAME,
            ROUND(SUM(BYTES) / (1024 * 1024)) AS FREE
        FROM
            DBA_FREE_SPACE
        GROUP BY
            TABLESPACE_NAME
    ) f
        ON  d.TABLESPACE_NAME = f.TABLESPACE_NAME
ORDER BY
    TABLESPACE_NAME;

最近 DB 触らなくなったなぁ…。