Oracle常用脚本(查询表空间使用情况)
select a.tablespace_name "表空间名称",
round(total / (1024 * 1024 * 1024), 2) "表空间大小(g)",
round(free / (1024 * 1024 * 1024), 2) "表空间剩余大小(g)",
round((total - free) / (1024 * 1024 * 1024), 2) "表空间使用大小(g)",
round((total - free) / total, 4) * 100 "使用率 %"
from (select tablespace_name, sum(bytes) free
from dba_free_space
group by tablespace_name) a,
(select tablespace_name, sum(bytes) total
from dba_data_files
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name;
查询结果如下:
sql脚本粘贴复制就可以直接使用。