1. 表佔用空間大小計算方法sql
Select S.SEGMENT_NAME ,DECODE(SUM(BYTES), NULL, 0, SUM(BYTES) / 1024 / 1024) Mbytes From DBA_SEGMENTS S Where S.SEGMENT_NAME = 'MTL_MATERIAL_TRANSACTIONS' --表名 And S.SEGMENT_TYPE = 'TABLE' Group By S.SEGMENT_NAME
2. 索引佔用空間大小計算方法code
Select S.SEGMENT_NAME ,DECODE(SUM(BYTES), NULL, 0, SUM(BYTES) / 1024 / 1024) Mbytes From DBA_SEGMENTS S Where S.SEGMENT_NAME = 'MTL_MATERIAL_TRANSACTIONS_N1' --索引 And S.SEGMENT_TYPE = 'INDEX' Group By S.SEGMENT_NAME
3. 分區表佔用空間大小計算方法索引
Select S.SEGMENT_NAME ,DECODE(SUM(BYTES), NULL, 0, SUM(BYTES) / 1024 / 1024) Mbytes From DBA_SEGMENTS S Where S.SEGMENT_TYPE = 'TABLE PARTITION' Group By S.SEGMENT_NAME
4. 表空間使用狀況class
SELECT A.TABLESPACE_NAME 表空間名稱, Round(A.BYTES, 2) "總空間(G)", Round(B.BYTES, 2) "未用空間(G)", ROUND(((A.BYTES - B.BYTES) / A.BYTES) * 100, 2) "使用率%" FROM (SELECT TABLESPACE_NAME, SUM(BYTES) / (1024 * 1024 * 1024) BYTES FROM DBA_DATA_FILES GROUP BY TABLESPACE_NAME) A, (SELECT TABLESPACE_NAME, SUM(BYTES) / (1024 * 1024 * 1024) BYTES FROM DBA_FREE_SPACE GROUP BY TABLESPACE_NAME) B WHERE A.TABLESPACE_NAME = B.TABLESPACE_NAME ORDER BY ((A.BYTES - B.BYTES) / A.BYTES) DESC;