Skip to content

Generate Tablespace Coalesce Statements (atsfree.gen)

This generator script creates ALTER TABLESPACE COALESCE statements for all tablespaces in the database. Coalescing combines adjacent free extents into larger free extents, reducing fragmentation.

select 'alter tablespace ' ||
tablespace_name ||
' coalesce;'
from sys.dba_tablespaces
order by tablespace_name
/
-- Basic usage
@atsfree.gen
-- No parameters required - generates for all tablespaces

This script does not prompt for any parameters - it generates statements for all tablespaces.

SELECT ANY DICTIONARY
-- OR --
SELECT ON DBA_TABLESPACES
-- Plus ALTER TABLESPACE privilege
alter tablespace EXAMPLE coalesce;
alter tablespace SYSAUX coalesce;
alter tablespace SYSTEM coalesce;
alter tablespace TEMP coalesce;
alter tablespace UNDOTBS1 coalesce;
alter tablespace USERS coalesce;
  • All Tablespaces: Generates statements for every tablespace
  • Alphabetical Order: Sorted by tablespace name
  • Simple Operation: No parameters needed
  • Fragmentation Reduction: Combines adjacent free space

Regular Maintenance

-- Coalesce all tablespaces during maintenance window
@atsfree.gen

After Large Deletes

-- Run after dropping multiple objects
@atsfree.gen