查看表空間使用情況(SQL)
阿新 • • 發佈:2019-05-07
mage border select 20px mono col gin 查詢 otto
1: --查詢表空間使用情況
2: SELECT Upper(F.TABLESPACE_NAME) "表空間名",
3: D.TOT_GROOTTE_MB "表空間大小(M)",
4: D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空間(M)",
5: To_char(Round(( D.TOT_GROOTTE_MB - F.TOTAL_BYTES ) / D.TOT_GROOTTE_MB * 100, 2), ‘990.99‘)
6: || ‘%‘"使用比",
7: F.TOTAL_BYTES "空閑空間(M)",
8: F.MAX_BYTES "最大塊(M)",
9: D.AUTOEXTENSIBLE "是否自增長",
10: D.INCREMENTSIZE "自增長大小(M)"
11: FROM (SELECT TABLESPACE_NAME,
12: Round(Sum(BYTES) / ( 1024 * 1024 ), 2) TOTAL_BYTES,
13: Round(Max(BYTES) / ( 1024 * 1024 ), 2) MAX_BYTES
14: FROM SYS.DBA_FREE_SPACE
15: GROUP BY TABLESPACE_NAME) F,
16: (SELECT DD.TABLESPACE_NAME,
17: Round(Sum(DD.BYTES) / ( 1024 * 1024 ), 2) TOT_GROOTTE_MB,
18: AUTOEXTENSIBLE,
19:--INCREMENT_BY的單位是數據塊的大小。數據塊大小一般為默認8k
20: Round(INCREMENT_BY * (select value/1024 from v$parameter where name=‘db_block_size‘)/1024, 2) INCREMENTSIZE
21: FROM SYS.DBA_DATA_FILES DD
22: GROUP BY DD.TABLESPACE_NAME,AUTOEXTENSIBLE,INCREMENT_BY) D
23: WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME
24: ORDER BY "表空間名"
顯示結果如下:
參考:https://www.cnblogs.com/xwdreamer/p/3511047.html
查看表空間使用情況(SQL)