OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.3.5

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & Certification
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.3.5
    iconOceanBase Database
    SQL - V 4.3.5
    SQL
    KV
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    Create a dynamic partitioned table

    Last Updated:2026-04-09 02:53:55  Updated
    share
    What is on this page
    Limitations and considerations
    Privilege requirements
    Syntax
    Dynamic partition management attributes
    Parameter limitations for dynamic partitions
    Examples
    References

    folded

    share

    In OceanBase Database, you can specify the dynamic partition management attribute of a table by using DYNAMIC_PARTITION_POLICY during table creation.

    This topic describes how to create a dynamic partitioned table by using SQL statements.

    Note

    For OceanBase Database V4.3.5, the DYNAMIC_PARTITION_POLICY parameter can be used to create a dynamical partitioned table starting from V4.3.5 BP2.

    Limitations and considerations

    • In the current version, creating a dynamic partitioned table requires at least one partition definition.
    • Only RANGE partitioned tables with a partitioning key of type date, timestamp, timestamp with local time zone, or number (with specified BIGINT_PRECISION precision) support enabling dynamic partition management.
    • Dynamic partition management can only be enabled for the partitions of a partitioned table and subpartitioned table.
    • After you precreate partitions or delete expired partitions, the partitions are not immediately created or deleted. Instead, a dynamic partition management task is automatically scheduled to run next, or you can manually schedule a dynamic partition management task. For more information, see Dynamic partition management tasks.

    Privilege requirements

    To create a dynamic partitioned table, you must have the CREATE TABLE privilege. For more information about the privileges in OceanBase Database, see Privilege types in Oracle-compatible mode.

    Syntax

    The SQL statement for creating a dynamically partitioned table is as follows:

    CREATE TABLE [IF NOT EXISTS] table_name (table_definition_list)
        DYNAMIC_PARTITION_POLICY [=] (dynamic_partition_policy_list)
        partition_option;
    
    dynamic_partition_policy_list:
        dynamic_partition_policy_option [, dynamic_partition_policy_option ...]
    
    dynamic_partition_policy_option:
        ENABLE = {true | false}
        | TIME_UNIT = {'hour' | 'day' | 'week' | 'month' | 'year'}
        | PRECREATE_TIME = {'-1' | '0' | 'n {hour | day | week | month | year}'}
        | EXPIRE_TIME = {'-1' | '0' | 'n {hour | day | week | month | year}'}
        | TIME_ZONE = {'default' | 'time_zone'}
        | BIGINT_PRECISION = {'none' | 'us' | 'ms' | 's'}
    

    Dynamic partition management attributes

    Attribute Description Required? Modifiable?
    ENABLE Specifies whether to enable dynamic partition management. Valid values:
    • true: specifies to enable dynamic partition management. This is the default value.
    • false: specifies to disable dynamic partition management.
    No Yes
    TIME_UNIT The time unit for partitioning, which indicates the interval of automatic partition boundaries. Valid values:
    • hour: partitions are created by hours.
    • day: partitions are created by days.
    • week: partitions are created by weeks.
    • month: partitions are created by months.
    • year: partitions are created by years.
    Yes No
    PRECREATE_TIME The time when partitions are pre-created. In each scheduled dynamic partition management task, partitions are pre-created to ensure that max_partition_upper_bound > now() + precreate_time. Valid values:
    • -1: the default value, which specifies not to pre-create partitions.
    • 0: specifies to pre-create only the current partition.
    • n {hour \| day \| week \| month \| year}: specifies to pre-create partitions for the corresponding time span. For example, 3 hour specifies to pre-create partitions for the last 3 hours.

    Note

    • If multiple partitions are to be pre-created, the interval of partition boundaries is TIME_UNIT.
    • The boundary of the first pre-created partition is the upper boundary of the largest existing partition, rounded up based on TIME_UNIT.

    No Yes
    EXPIRE_TIME The partition expiration time. In each scheduled dynamic partition management task, all partitions whose upper boundaries are earlier than now() - expire_time will be deleted. Valid values:
    • -1: the default value, which specifies that partitions never expire.
    • 0: specifies that partitions other than the current partition expire.
    • n {hour \| day \| week \| month \| year}: the partition expiration time. For example, 1 day specifies that the partition expiration time is 1 day.
    No Yes
    TIME_ZONE The time zone to be used for comparing the current time with the partitioning key values of the date and timestamp data types. Valid values:
    • default: the default value, which specifies not to configure a time zone and to use the tenant time zone instead. The time_zone field must be set to default for data types other than the preceding three types.
    • time_zone: a custom time zone offset, such as +08:00.
    No No
    BIGINT_PRECISION The timestamp precision of the number-typed partitioning key. Valid values:
    • none: the default value, which specifies no precision (that is, the partitioning key is not of the number type).
    • us: microsecond precision.
    • ms: millisecond precision.
    • s: second precision.
    No No

    For more information about table creation syntax and parameter descriptions, see CREATE TABLE.

    Parameter limitations for dynamic partitions

    • PRECREATE_TIME: You can precreate at most 2,048 partitions.
    • TIME_ZONE: If the partitioning key is of the date or timestamp type, you can specify a custom time zone offset for the TIME_ZONE parameter. For other types, the value of the TIME_ZONE parameter must be default.
    • BIGINT_PRECISION: This parameter can only be set to us, ms, or s when the partitioning key type is number. For other partitioning key types, the value of this parameter must be none.
    • The values of the TIME_UNIT, TIME_ZONE, and BIGINT_PRECISION parameters specified cannot be modified.

    Examples

    Create a dynamic partitioned table named test_tbl1 and set the dynamic partitioning attributes as follows:

    • Partition boundaries are divided by hour.
    • Pre-create partitions for the 3 hours following the current time.
    • Delete partitions whose upper boundary is earlier than 1 day before the current time.
    • Use Beijing time (UTC+8) to determine the time, ensuring that partition boundaries and expiration logic are based on this time zone.
    • The partition key col2 is of type TIMESTAMP, so there is no need to configure the timestamp precision for number.
    CREATE TABLE test_tbl1 (col1 INT, col2 TIMESTAMP)
        DYNAMIC_PARTITION_POLICY(
            ENABLE = true,
            TIME_UNIT = 'hour',
            PRECREATE_TIME = '3 hour',
            EXPIRE_TIME = '1 day',
            TIME_ZONE = '+8:00',
            BIGINT_PRECISION = 'none')
        PARTITION BY RANGE (col2)(
            PARTITION P0 VALUES LESS THAN (TIMESTAMP '2024-11-11 13:30:00')
            );
    

    Note

    The actions of pre-creating partitions and deleting expired partitions will not be executed immediately after the table is created. You need to wait for the next automatic scheduling of the dynamic partition management task, or manually trigger the dynamic partition management task. For more information, see Dynamic partition management task.

    References

    • Overview of dynamic partitioning
    • Query a dynamic partitioned table
    • Modify a dynamic partitioned table
    • Dynamic partition management tasks

    Previous topic

    Overview of dynamic partitioning
    Last

    Next topic

    Query a dynamic partitioned table
    Next
    What is on this page
    Limitations and considerations
    Privilege requirements
    Syntax
    Dynamic partition management attributes
    Parameter limitations for dynamic partitions
    Examples
    References