Oracle 查找表空间使用情况
查找Oracle数据库空闲空间占比,需要用到两个视图:
1. DBA_DATA_FILES
DBA_DATA_FILES视图则记录的是物理数据文件的信息,这些信息包括数据文件的名称、大小、所属表空间等信息.
数据库在mount状态下,从dba_data_files查不出数据的,必须在open下才行.
2. DBA_FREE_SPACE
DBA_FREE_SPACE视图记录Oracle还有多少表空间剩余空间.
查询语句如下:
1 SELECT Upper(F.TABLESPACE_NAME) "表空间名", 2 T.TOT_TABLESPACE_SIZE_MB "表空间大小(M)", 3 T.TOT_TABLESPACE_SIZE_MB - F.TOTAL_BYTES "已使用空间(M)", 4 To_char(Round((T.TOT_TABLESPACE_SIZE_MB - F.TOTAL_BYTES) / T.TOT_TABLESPACE_SIZE_MB * 100, 2), '990.99') || '%' "使用比", 5 F.TOTAL_BYTES "空闲空间(M)", 6 F.MAX_BLOCK "最大块(M)" 7 FROM (SELECT TABLESPACE_NAME, 8 Round(Sum(BYTES) / (1024 * 1024), 2) TOTAL_BYTES, 9 Round(Max(BYTES) / (1024 * 1024), 2) MAX_BLOCK 10 FROM SYS.DBA_FREE_SPACE 11 GROUP BY TABLESPACE_NAME) F, 12 (SELECT D.TABLESPACE_NAME, 13 Round(Sum(D.BYTES) / (1024 * 1024), 2) TOT_TABLESPACE_SIZE_MB 14 FROM SYS.DBA_DATA_FILES D 15 GROUP BY D.TABLESPACE_NAME) T 16 WHERE T.TABLESPACE_NAME = F.TABLESPACE_NAME 17 ORDER BY 1;
测试预览如下:
相关推荐
bfcady 2020-08-16
Hody 2020-08-16
FightFourEggs 2020-08-16
流云追风 2020-07-04
dataminer 2020-06-25
lidongliang 2020-08-16
warden00 2020-06-11
zhangchaoming 2020-06-04
FightFourEggs 2020-06-02
FightFourEggs 2020-05-28
elitechen 2020-05-21
zhangchaoming 2020-05-17
流云追风 2020-05-14
bianxq 2020-04-27
流云追风 2020-04-22
oraclemch 2020-04-19
oraclemch 2020-04-10
oraclemch 2020-02-21
FightFourEggs 2020-02-12
Streamoutput 2020-02-09
talkingDB 2020-02-03
LuoXinLoves 2020-02-02
Streamoutput 2020-01-21
Streamoutput 2020-01-10
zhangchaoming 2020-01-04