DBAtlas · Atlas de operaciones de bases de datos

Dividir y combinar particiones en línea

OracleParticionamiento

Comando

-- SPLIT: split a range partition in two, keep indexes usable
ALTER TABLE customer_app.sale_part
  SPLIT PARTITION p2026_h2 AT (DATE '2026-10-01')
  INTO (PARTITION p2026_q3, PARTITION p2026_q4)
  UPDATE INDEXES ONLINE;

-- MERGE: merge two adjacent partitions
ALTER TABLE customer_app.sale_part
  MERGE PARTITIONS p2026_q3, p2026_q4 INTO PARTITION p2026_h2
  UPDATE INDEXES ONLINE;

-- ADD: new partition at the end (when there is no MAXVALUE)
ALTER TABLE customer_app.sale_part
  ADD PARTITION p2027 VALUES LESS THAN (DATE '2028-01-01');

-- Check: partition bounds and UNUSABLE index partitions
SELECT partition_name, partition_position, high_value, num_rows
FROM   dba_tab_partitions
WHERE  table_owner = 'CUSTOMER_APP' AND table_name = 'SALE_PART'
ORDER  BY partition_position;

SELECT index_name, partition_name, status
FROM   dba_ind_partitions
WHERE  index_owner = 'CUSTOMER_APP' AND status <> 'USABLE';

Qué hace

SPLIT divide una partición en dos en un valor límite (12c+: en varias); MERGE combina particiones adyacentes. Con ONLINE, el DML continúa durante la operación; con UPDATE INDEXES, los índices locales y globales no pasan a UNUSABLE.

Cuándo usarlo

Para dividir una partición MAXVALUE/"otros" que ha crecido, combinar particiones antiguas pequeñas antes de archivarlas o cambiar el esquema de particionamiento (de mensual a trimestral).

Precaución

Requiere la opción Partitioning (EE con costo adicional); ONLINE requiere Enterprise Edition. SPLIT/MERGE reescribe físicamente los datos: lento en particiones grandes, genera redo/undo y espacio temporal. Sin ONLINE la tabla queda bloqueada para DML durante la operación; sin UPDATE INDEXES los índices globales pasan a UNUSABLE. Dividir una partición vacía es rápido (fast split).

Abrir en DBAtlas →

Relacionado