Oracle SQL statement using the display table space usage

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;

After executing the script, the display is as follows:

Guess you like

Origin www.linuxidc.com/Linux/2019-09/160607.htm