1 SELECT UPPER(F.TABLESPACE_NAME) TABLESPACE_NAME, -- 表空间名, 2 D.TOT_GROOTTE_MB TOT_GROOTTE_MB, -- 表空间大小(G), 3 D.TOT_GROOTTE_MB - F.TOTAL_BYTES USEDMB, ---已使用空间(G), 4 TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100, 5 2), 6 '990.99') || '%' USAGERATIO, -- 使用比, 7 F.TOTAL_BYTES, -- 空闲空间(G), 8 d.MAXBYTES --表空间最大能扩到多大 9 10 FROM (SELECT TABLESPACE_NAME, 11 ROUND(SUM(BYTES) / (1024 * 1024* 1024), 3) TOTAL_BYTES 12 FROM SYS.DBA_FREE_SPACE 13 GROUP BY TABLESPACE_NAME) F, 14 (SELECT DD.TABLESPACE_NAME, 15 ROUND(SUM(DD.BYTES) / (1024 * 1024* 1024), 3) TOT_GROOTTE_MB, 16 ROUND(sum(dd.MAXBYTES)/(1024 * 1024* 1024), 3) MAXBYTES 17 FROM SYS.DBA_DATA_FILES DD 18 GROUP BY DD.TABLESPACE_NAME) D 19 WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME 20 ORDER BY 2 DESC
查询表空间所有相关信息sql:select * from dba_data_files;