<jsp:directive.page pageEncoding="UTF-8" />
select
  ds.tablespace_name,
  ds.owner,
  ds.segment_name||':'||ds.partition_name SEGMENTNAME,
  ds.segment_type,
  dfts.max_free/1024 MAX_FREE_KB,
  decode(dfts.min_extlen,0,ds.next_extent/1024,
         dfts.min_extlen*ceil(next_extent/dfts.min_extlen)/1024) NEXT_EXT_KB
from
  dba_segments  ds,
  (select
    dt.tablespace_name ,
    decode(max(bytes),null,0,max(bytes)) max_free,
    min_extlen
   from dba_free_space dfs,dba_tablespaces dt
   where dfs.tablespace_name (+)=dt.tablespace_name
   group by dt.tablespace_name,dt.min_extlen)  dfts 
where
  ds.tablespace_name =dfts.tablespace_name and
  ds.next_extent > dfts.max_free
order by 1,6 desc
