select substr(a.tablespace_name,1,20) "Tablespace_name",
       round(sum(a.total1)/1024/1024,0) "Total (M)",
       round(sum(a.total1)/1024/1024,0)-round(sum(a.sum1)/1024/1024,0) "Usado (M)",
       round(sum(a.sum1)/1024/1024,0) "Libre (M)",
       round(sum(a.maxb)/1024/1024,0) "Frag. >(M)",
       round(round(sum(a.sum1)/1024/1024,1)*100/round(sum(a.total1)/1024/1024,1),1) "Pct_Libre",
       max(a.cnt) "Fragments"
from
       (select tablespace_name,
               0 total1,
               sum(bytes) sum1,
               max(bytes) maxb,
               count(bytes) cnt
        from dba_free_space
        group by tablespace_name
        union
        select tablespace_name,
               sum(bytes) total1, 0,0,0
        from dba_data_files
        group by tablespace_name) a
where a.tablespace_name like upper ('%&1%')
group by a.tablespace_name
order by 6 asc
/
