SELECT Upper(F.TABLESPACE_NAME) AS 表空间名
, round(D.TOT_GROOTTE_MB / 1024, 2) AS "总大小(G)"
, round((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / 1024, 2) AS "已使用空间(G)"
, round(F.TOTAL_BYTES / 1024, 2) AS "空闲空间(G)"
, Round((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_MB, 4) * 100 AS "已使用占最大比例(%)"
FROM (
SELECT TABLESPACE_NAME
, Round(SUM(BYTES) / (1024 * 1024), 2) AS TOTAL_BYTES
, Round(MAX(BYTES) / (1024 * 1024), 2) AS MAX_BYTES
FROM SYS.DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME
) F, (
SELECT tablespace_name
, Round(SUM(BYTES) / (1024 * 1024), 2) AS TOT_GROOTTE_MB
, Round(SUM(maxbytes) / (1024 * 1024), 2) AS TOT_MB
FROM (
SELECT file_id, tablespace_name, bytes
, CASE
WHEN autoextensible = 'NO' THEN bytes
ELSE maxbytes
END AS maxbytes
FROM dba_data_files
)
GROUP BY tablespace_name
) D
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME
标签:1024,MB,BYTES,TOT,使用量,TABLESPACE,SQL,ORACLE,Round
From: https://blog.51cto.com/chengzheng183/6350643