OceanBase logo

OceanBase

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

Product Overview
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

OceanBase

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

Product Overview
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.6.0

    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.6.0
    iconOceanBase Database
    SQL - V 4.6.0
    SQL
    KV
    • V 4.6.0
    • 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

    Modify a dynamic partitioned table

    Last Updated:2026-05-07 11:26:25  Updated
    share
    What is on this page
    Limitations and considerations
    Privilege requirements
    Syntax
    Dynamic partition management attributes
    Examples
    References

    folded

    share

    In OceanBase Database, you can modify the dynamic partition management attributes of a table by updating DYNAMIC_PARTITION_POLICY.

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

    Note

    For OceanBase Database V4.3.5, the DYNAMIC_PARTITION_POLICY parameter is supported for creating dynamic partitioned tables starting from V4.3.5 BP2.

    Limitations and considerations

    After modifying the dynamic partition management parameters, the actions of pre-creating partitions and deleting expired partitions will not take effect immediately. 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 about how to schedule a dynamic partition management task, see Dynamic partition management task.

    Privilege requirements

    To modify a dynamic partitioned table, you need the ALTER privilege. For more information about privileges in OceanBase Database, see Privilege types in Oracle-compatible mode.

    Syntax

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

    ALTER TABLE table_name [SET] DYNAMIC_PARTITION_POLICY [=] (dynamic_partition_policy_list);
    
    dynamic_partition_policy_list:
        dynamic_partition_policy_option [, dynamic_partition_policy_option ...]
    
    dynamic_partition_policy_option:
        ENABLE = {true | false}
        | PRECREATE_TIME = {'-1' | '0' | 'n {hour | day | week | month | year}'}
        | EXPIRE_TIME = {'-1' | '0' | 'n {hour | day | week | month | year}'}
    

    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
    PRECREATE_TIME Specifies the precreation time. Partitions are precreated in an scheduling task of dynamic partition management so that max_partition_upper_bound > now() + precreate_time. Valid values:
    • -1: specifies not to precreate partitions. This is the default value.
    • 0: specifies to precreate only the current partition.
    • n {hour \| day \| week \| month \| year}: specifies to precreate partitions within the specified time span. For example, 3 hour specifies to precreate partitions within 3 hours.

    Note

    • When you want to precreate multiple partitions, the intervals between partition boundaries must be TIME_UNIT.
    • The boundary of the first precreated partition is the upper boundary of the largest existing partition, rounded up to the nearest value of TIME_UNIT.

    No Yes
    EXPIRE_TIME Specifies the partition expiration time. Partitions are deleted in an scheduling task of dynamic partition management so that partition_upper_bound < now() - expire_time. Valid values:
    • -1: specifies that partitions never expire. This is the default value.
    • 0: specifies that all partitions except the current one expire.
    • n {hour \| day \| week \| month \| year}: specifies the partition expiration time. For example, 1 day specifies that the partition expiration time is 1 day.
    No Yes

    For more information about how to modify the syntax of a table, see ALTER TABLE.

    Examples

    1. Query the dynamic partitioning information about the test_tbl1 table.

      SELECT * FROM sys.DBA_OB_DYNAMIC_PARTITION_TABLES
      WHERE TABLE_NAME = 'TEST_TBL1';
      

      The query result is as follows:

      +---------------+------------+----------+----------------------------------------+--------+-----------+----------------+-------------+-----------+------------------+
      | DATABASE_NAME | TABLE_NAME | TABLE_ID | MAX_HIGH_BOUND_VAL                     | ENABLE | TIME_UNIT | PRECREATE_TIME | EXPIRE_TIME | TIME_ZONE | BIGINT_PRECISION |
      +---------------+------------+----------+----------------------------------------+--------+-----------+----------------+-------------+-----------+------------------+
      | SYS           | TEST_TBL1  |   507940 | Timestamp '2024-11-11 13:30:00.000000' | TRUE   | HOUR      | 3HOUR          | 1DAY        | +8:00     | NONE             |
      +---------------+------------+----------+----------------------------------------+--------+-----------+----------------+-------------+-----------+------------------+
      1 row in set
      
    2. Modify the dynamic partitioning settings for the test_tbl1 table as follows:

      • Precreate partitions for one day starting from the current time.
      • Partitions never expire.
      ALTER TABLE test_tbl1 DYNAMIC_PARTITION_POLICY(
          ENABLE = true,
          PRECREATE_TIME = '1 day',
          EXPIRE_TIME = '-1'
      );
      
    3. Query the dynamic partitioning information about the test_tbl1 table again.

      SELECT * FROM sys.DBA_OB_DYNAMIC_PARTITION_TABLES
      WHERE TABLE_NAME = 'TEST_TBL1';
      

      The query result is as follows:

      +---------------+------------+----------+----------------------------------------+--------+-----------+----------------+-------------+-----------+------------------+
      | DATABASE_NAME | TABLE_NAME | TABLE_ID | MAX_HIGH_BOUND_VAL                     | ENABLE | TIME_UNIT | PRECREATE_TIME | EXPIRE_TIME | TIME_ZONE | BIGINT_PRECISION |
      +---------------+------------+----------+----------------------------------------+--------+-----------+----------------+-------------+-----------+------------------+
      | SYS           | TEST_TBL1  |   507940 | Timestamp '2024-11-11 13:30:00.000000' | TRUE   | HOUR      | 1DAY           | -1          | +8:00     | NONE             |
      +---------------+------------+----------+----------------------------------------+--------+-----------+----------------+-------------+-----------+------------------+
      1 row in set
      

      Note

      After modifying the dynamic partition management parameters, the actions of pre-creating partitions and deleting expired partitions will not take effect immediately. 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
    • Create a dynamic partitioned table
    • Query a dynamic partitioned table
    • Manage dynamic partitions

    Previous topic

    Query a dynamic partitioned table
    Last

    Next topic

    Dynamic partition management tasks
    Next
    What is on this page
    Limitations and considerations
    Privilege requirements
    Syntax
    Dynamic partition management attributes
    Examples
    References