sql >> Base de Datos >  >> RDS >> Oracle

Oracle:eliminar varias particiones

Puedes usar dynamic sql en anonymous pl/sql bloquear;

Begin
  for i in (select part_name from ...  //expression to get partition names) loop
    execute immediate 'ALTER TABLE TMP DROP PARTITION ' || i.part_name;
  end loop;
end;

Para eliminar varias particiones de una vez, entonces;

declare
  v_part varchar(1000);
Begin
  select LISTAGG(partition_name, ', ') WITHIN GROUP (ORDER BY partition_name DESC)
  into v_part  
  from ...  //expression to get partition names;
  execute immediate 'ALTER TABLE TMP DROP PARTITION ' || v_part;
end;