Dynamically Delete Old Partitions

June 8th, 2011 No Comments   Posted in Oracle How-To

Are you looking to delete older partitions in an Oracle database? Here is a basic SQL query that will give you what you need.

select ‘ALTER TABLE ‘||table_owner||’.'||table_name
||’ DROP PARTITION ‘
||partition_name||’ UPDATE INDEXES;’
from dba_tab_partitions
where table_owner = ‘O1DW’
and table_name = ‘ACME_FAILED_DETAIL’
order by PARTITION_POSITION;

Modify to your specific needs.