SELECT b.tablespace_name "表空间名",
round(b.all_byte) "总空间(M)",
round(b.all_byte-a.free_byte) "已使用(M)",
round(a.free_byte) "剩余空间",
round((a.free_byte/b.all_byte)*100)||'%' "剩余百分比"
FROM
(SELECT tablespace_name,SUM(nvl(bytes,0))/1024/1024 free_byte FROM dba_free_space GROUP BY tablespace_name) a,
(SELECT tablespace_name,SUM(nvl(bytes,0))/1024/1024 all_byte FROM dba_data_files GROUP BY tablespace_name) b
WHERE b.tablespace_name = a.tablespace_name(+)
ORDER BY 1,5;
//SQL/1228