RANGE COLUMNS INTERVAL Partitioning Type
A RANGE COLUMNS variant that adds new partitions automatically, by a fixed time interval, as data is written.
Adding an INTERVAL clause to a RANGE COLUMNS partitioned table makes the server extend the table's partitions automatically. You define one starting partition; whenever a write reaches the table, MariaDB adds as many partitions of the given interval as it takes for the newest partition to cover the current date and time.
This removes the routine maintenance that a time-ranged table normally needs, where a scheduled job or a person has to run ALTER TABLE ... ADD PARTITION before the data catches up with the last defined partition.
In every other respect the table behaves like an ordinary RANGE COLUMNS partitioned table.
Syntax
PARTITION BY RANGE COLUMNS (col_name)
INTERVAL interval_expression time_unit [AUTO]
(
PARTITION partition_name VALUES LESS THAN (value)
[, PARTITION partition_name VALUES LESS THAN (value) ... ]
)Oracle's interval functions are accepted as an alternative spelling of the interval:
PARTITION BY RANGE COLUMNS (col_name)
INTERVAL ( NUMTODSINTERVAL(number, 'DAY' | 'HOUR' | 'MINUTE' | 'SECOND') )
(
PARTITION partition_name VALUES LESS THAN (value)
[, PARTITION partition_name VALUES LESS THAN (value) ... ]
)
PARTITION BY RANGE COLUMNS (col_name)
INTERVAL ( NUMTOYMINTERVAL(number, 'YEAR' | 'MONTH') )
(
PARTITION partition_name VALUES LESS THAN (value)
[, PARTITION partition_name VALUES LESS THAN (value) ... ]
)The AUTO keyword is optional and has no effect — automatic partition creation is always enabled when an INTERVAL clause is present. SHOW CREATE TABLE does not report it.
Requirements and Restrictions
At least one partition must be defined.
PARTITION BY RANGE COLUMNS (col) INTERVAL 1 DAYon its own fails withFor RANGE partitions each partition must be defined.No partition may use
MAXVALUE, at table creation or later throughALTER TABLE ... ADD PARTITION. AMAXVALUEpartition would swallow every future row and make automatic creation pointless.The interval must be positive and must not carry a sub-second component.
INTERVAL 1.1 SECOND_MICROSECONDis rejected, as areINTERVAL 0 DAYandINTERVAL -1 DAY.For a
DATEcolumn, the interval must be at least one day.NUMTODSINTERVAL()accepts onlyDAY,HOUR,MINUTEandSECOND;NUMTOYMINTERVAL()accepts onlyYEARandMONTH. In both forms the number must be greater than zero.The interval may be an expression, but not a subquery or a stored function call.
LIST COLUMNSpartitioning does not acceptINTERVAL.Subpartitioning is allowed, restricted as usual to
[LINEAR] KEYand[LINEAR] HASH.The 8192-partition limit still applies. A short interval combined with an old starting partition can reach it in a single statement, which fails with
Too many partitions (including subpartitions) were defined.
How Partitions Are Added
The upper bound of the highest partition is the transition point. When a write arrives, the server repeatedly adds the interval to that bound until it passes the current date and time, and creates one partition per step. New partitions are named pN, where N is chosen from the first gap in the existing pN names that is large enough to hold all of them.
Automatic creation happens for these statements:
It also happens when one of those statements runs inside a trigger body, and on a replica when it applies the corresponding row events. Read-only statements and DDL never create partitions.
Partitions are created up to the current time, not up to the value being written. A row dated further in the future than the newest partition's bound still fails with Table has no partition for value from column_list — and the partitions covering the present are created anyway, because the statement is rolled back but the partition changes are not.
Rows earlier than the lowest partition are not accommodated either; partitions are only ever added at the top. Automatic creation happens only in DML, so an ALTER TABLE that introduces an INTERVAL clause whose starting partition does not already cover the existing rows fails.
Transactions and Replication
Adding partitions does not cause the implicit commit that DDL normally would, so the surrounding transaction stays open. If that transaction is rolled back, the rows are undone but the new partitions remain.
The implicit ADD PARTITION is not written to the binary log. A replica creates the same partitions itself while applying the row events, so primary and replica converge without a separate DDL event.
Examples
Start from a single partition covering everything before 20 April 2026, and add a day's worth at a time:
With the server clock at 2 May 2026, a single insert fills in the missing days:
The same table using Oracle's interval spelling, and a TIMESTAMP column:
Subpartitioned by KEY:
INTERVAL can be added to or removed from an existing table by repartitioning it:
See Also
This page is licensed: CC BY-SA / Gnu FDL
Last updated
Was this helpful?

