使用SQL语句显示Oracle表空间使用率

2022-08-18 16:37:09 浏览数 (2)

在日常运维中,可以使用如下SQL语句显示Oracle表空间使用率:

SELECT a.tablespace_name,       ROUND(a.total_size) "total_size(MB)",       ROUND(a.total_size) - ROUND(b.free_size,3) "used_size(MB)",       ROUND(b.free_size,3) "free_size(MB)",       ROUND(b.free_size/total_size*100,2) || '%' free_rate FROM  (SELECT tablespace_name,SUM(bytes)/1024/1024 total_size         FROM dba_data_files         GROUP BY tablespace_name) a,       (SELECT tablespace_name,SUM(bytes)/1024/1024 free_size         FROM dba_free_space         GROUP BY tablespace_name) b WHERE  a.tablespace_name = b.tablespace_name;

执行脚本后,显示效果如下:

0 人点赞