Updated on 2026-08-04 GMT+08:00

INTERVAL RANGE

Scenarios

An INTERVAL RANGE partitioned table is an extension of a RANGE partitioned table. If data to be inserted into a RANGE partitioned table falls outside the range of an existing partition, it cannot be inserted and an error will be returned.

If there is an INTERVAL RANGE partitioned table in a database, the database can create a partition based on rules specified by the INTERVAL clause when data to be inserted exceeds the range of an existing partition.

Prerequisites

Constraints

  • INTERVAL RANGE partitioned tables support only HASH or KEY subpartitions.
  • If an INTERVAL RANGE rule is in RANGE COLUMNS(column_list) INTERVAL([type], value) format:
    • column_list specifies only a single partition key, which must be of the INTEGER, DATE, TIME, or DATETIME type.
    • If the partition key is of the INTEGER type, the interval type (type) can be left blank.
    • If the partition key is of the DATE type, the interval type (type) can only be YEAR, QUARTER, MONTH, WEEK, or DAY.
    • If the partition key is of the TIME type, the interval type (type) can only be HOUR, MINUTE, or SECOND.
    • If the partition key is of the DATETIME type, the interval type (type) can be YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, or SECOND.
    • The interval value (value) must be a positive integer.
    • If the interval type (type) is SECOND, the interval cannot be less than 60.
  • If an INTERVAL RANGE rule is in RANGE(expr) INTERVAL(value) format, expr must be an integer, and value must be a positive integer.
  • You cannot execute the INSERT ... SELECT, INSERT ... ON DUPLICATE KEY UPDATE, and UPDATE statements to add partitions.
  • When you execute the LOAD DATA statement to import data, automatic partition creation will not be triggered. (If the range of the partition covers all data, data can be imported. If the range of the partition does not cover all data, automatic partition creation will not be triggered and data cannot be imported.)
  • Partitions cannot be added in explicit transactions or in SQL statements following set autocommit=0.
  • Prefix _p is reserved for automatically created partitions. If you use this prefix for custom partitions, automatic partition creation may fail.
  • The SET INTERVAL([type], value) clause applies only to INTERVAL RANGE and RANGE partitioned tables. If these tables have subpartitions, the subpartitions must be of the HASH or KEY type.
  • The values of type and value in the SET INTERVAL([type], value) clause must be restricted by the partition expression expr or the partition key column_list of the original table.

How to Use

Table 1 Parameter description

Parameter

Level

Description

rds_interval_range_enabled

Global

Enables or disables INTERVAL RANGE.

Value:

  • ON: INTERVAL RANGE is enabled.
  • OFF: INTERVAL RANGE is disabled.

Creating an INTERVAL RANGE Partitioned Table

The definition format of an INTERVAL RANGE partitioned table is similar to that of a RANGE partitioned table. The only difference is that the INTERVAL clause is added.

Conversion Between INTERVAL RANGE Partitioned Tables and Other Types of Tables

Other types of tables can be converted to INTERVAL RANGE partitioned tables, and vice versa.

SET INTERVAL Clause Usage

You can use the SET INTERVAL clause to modify the interval type and value of the INTERVAL clause defined in the INTERVAL RANGE partitioned table, or eliminate or add the INTERVAL clause.