Criar particionamento interval e converter uma tabela range existente para interval
OracleParticionamentoComando
-- New table: a partition is created automatically for each month
CREATE TABLE customer_app.measurements (
ts DATE NOT NULL,
sensor_id NUMBER,
value NUMBER)
PARTITION BY RANGE (ts) INTERVAL (NUMTOYMINTERVAL(1, 'MONTH'))
( PARTITION p_first VALUES LESS THAN (DATE '2026-01-01') );
-- Convert an existing range table to interval (there must be no MAXVALUE partition):
ALTER TABLE customer_app.sale_part SET INTERVAL (NUMTOYMINTERVAL(1, 'MONTH'));
-- Back to range: ALTER TABLE customer_app.sale_part SET INTERVAL ();
-- Rename a system-named partition to a meaningful name:
ALTER TABLE customer_app.measurements RENAME PARTITION FOR (DATE '2026-03-15') TO p2026_03;
-- Check:
SELECT partition_name, partition_position, interval, high_value
FROM dba_tab_partitions
WHERE table_owner = 'CUSTOMER_APP' AND table_name = 'MEASUREMENTS'
ORDER BY partition_position;
SELECT table_name, partitioning_type, interval
FROM dba_part_tables
WHERE owner = 'CUSTOMER_APP';O que faz
O particionamento interval cria automaticamente uma nova partição quando chega a primeira linha além do último limite, eliminando erros ORA-14400 causados por esquecer a partição do mês seguinte. SET INTERVAL converte uma tabela range existente sem mover dados.
Quando usar
Para tabelas que crescem por data, como séries temporais, logs e pedidos, e para reduzir scripts de manutenção de partições.
Atenção
Exige a opção Partitioning (EE com custo extra). A chave de partição deve ser uma única coluna NUMBER/DATE/TIMESTAMP; uma partição MAXVALUE deve ser removida antes. Uma data errada ou extrema (ex.: ano 9999) abre uma partição distante e distorce a numeração das partições; com intervalos estreitos você pode se aproximar do limite de 1,048,575 partições (ORA-14300), então valide as datas na aplicação. As partições automáticas vão para o tablespace padrão da tabela (direcione-as com STORE IN).