select 'alter database datafile '||fs.file_id||' resize '||to_char(trunc((max(df.bytes)-sum(fs.bytes))/1024/1024,-2)+100)||'M;'
  from dba_free_space fs, dba_data_files df,
     (select file_id, max(block_id) maxblk from dba_extents group by file_id) maxe
 where fs.file_id = df.file_id
   and fs.file_id = maxe.file_id(+)
   and block_id > nvl(maxe.maxblk,0)
group by fs.file_id order by 1
/