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 Developer Center

V4.4.0

  • Topics Overview
  • Overview
    • What is ODC?
    • Features
    • Architecture
    • Limitations
    • ODC console
  • Quick Start
    • Client ODC
      • Overview
      • Install Client ODC
      • Use Client ODC
    • Web ODC
      • Overview
      • Deploy Web ODC
      • Use Web ODC
  • Data Source Management
    • Create a data source
    • Data sources and project collaboration
    • Database O&M
      • Session management
      • Global variable management
      • Recycle bin management
  • SQL Development
    • Edit and execute SQL statements
    • Perform PL compilation and debugging
    • Use the command-line window
    • Edit and export the result set of an SQL statement
    • Execution analysis
    • Generate test data
    • System settings
    • Database objects
      • Table objects
        • Overview
        • Create a table
      • View objects
        • Overview
        • Create a view
        • Manage views
      • Materialized view objects
        • Overview
        • Create a materialized view
        • Manage materialized views
      • Function objects
        • Overview
        • Create a function
        • Manage functions
      • Stored procedure objects
        • Overview
        • Create a stored procedure
        • Manage stored procedures
      • Sequence objects
        • Overview
        • Create a sequence
        • Manage sequences
      • Package objects
        • Overview
        • Create a program package
        • Manage program packages
      • Trigger objects
        • Overview
        • Create a trigger
        • Manage triggers
      • Type objects
        • Overview
        • Create a type
        • Manage types
      • Synonym objects
        • Overview
        • Create a synonym
        • Manage synonyms
  • Import and Export
    • Import schemas and data
    • Export schemas and data
  • Database Change Management
    • Manage user permissions
      • Users and roles
      • Automatic authorization
      • User permission management
    • Project collaboration management
    • Risk levels, risk identification rules, and approval processes
    • SQL check specifications
    • SQL window specification
    • Database change management
    • Manage changes to logical databases
    • Batch database change management
    • Online schema changes
    • Synchronize shadow tables
    • Schema comparison
  • Data Lifecycle Management
    • Data archiving
    • Data cleanup
    • Manage partitioning plans
      • Manage partitioning plans
      • Set partitioning strategies
      • Examples of partitioning strategies
    • SQL plan task
  • Data Masking and Auditing
    • Desensitize data
    • Operation records
  • Notification Management
    • Overview
    • View notification records
    • Manage notification channels
      • Create a notification channel
      • View, edit, and delete a notification channel
      • Configure a custom channel
    • Manage notification rules
  • System Integration
    • Login integration
    • Approval integration
    • SQL approval integration
    • Bastion host integration
  • Deployment Guide
    • Deployment overview
    • Preparations before deployment
    • Deploy ODC in single-node mode
    • Deploy ODC in high-availability mode
    • Deployment verification
  • Upgrade Guide
    • Upgrade Overview
    • Preparations before upgrade
    • Update single-node ODC
    • Update high-avaliability ODC
    • Upgrade verification
    • Rollback after upgrade failed
  • Best Practices
    • Tips for SQL development
    • Explore ODC team workspaces
    • Understanding real-time SQL diagnostics for OceanBase AP
    • OceanBase historical database solutions
    • ODC SQL check for automatic identification of high-risk operations
    • Integration with ODC enterprise-level account system
    • Manage and modify sharded databases and tables via ODC
    • Data masking and control practices
    • Enterprise-level control and collaboration: Safeguard every database change
  • Troubleshooting
    • ODC troubleshooting process
    • Collect message
      • View the runtime environment and version information
      • View web ODC logs
      • View client ODC logs
      • View end-to-end ODC-related logs
      • View ODC MetaDB data
      • Query the index status in OceanBase Database V4.x
      • Query the index status in OceanBase Database V1.4.x to V3.2.x
      • Collect JVM runtime information
      • Use tcpdump to capture packets
    • FAQ
      • Installation of client ODC
      • Web ODC deployment and startup
      • Connection Information
      • Command-line window
      • DDL statement display
  • Common features
  • Release Notes
    • V4.4
      • ODC V4.4.0
    • V4.3
      • ODC V4.3.4
      • ODC V4.3.3
      • ODC V4.3.2
      • ODC V4.3.1
      • ODC V4.3.0
    • V4.2
      • ODC V4.2.4
      • ODC V4.2.3
      • ODC V4.2.2
      • ODC V4.2.1
      • ODC V4.2.0
    • V4.1
      • ODC V4.1.3
      • ODC V4.1.2
      • ODC V4.1.1
      • ODC V4.1.0
    • V4.0
      • ODC V4.0.2
      • ODC V4.0.0
    • V3.4
      • ODC V3.4.0
    • V3.3
      • ODC V3.3.3
      • ODC V3.3.2
      • ODC V3.3.1
      • ODC V3.3.0
    • V3.2
      • ODC V3.2.3
      • ODC V3.2.2
      • ODC V3.2.1
      • ODC V3.2.0

Download PDF

Topics Overview What is ODC? Features Architecture Limitations ODC console Overview Install Client ODC Use Client ODC Overview Deploy Web ODC Use Web ODC Create a data source Data sources and project collaboration Session management Global variable management Recycle bin management Edit and execute SQL statements Perform PL compilation and debugging Use the command-line window Edit and export the result set of an SQL statement Execution analysis Generate test data System settings Import schemas and data Export schemas and data Users and roles Automatic authorization User permission management Project collaboration management Risk levels, risk identification rules, and approval processes SQL check specifications SQL window specification Database change management Manage changes to logical databases Batch database change management Online schema changes Synchronize shadow tables Schema comparison Data archiving Data cleanup Manage partitioning plans Set partitioning strategies Examples of partitioning strategies SQL plan task Desensitize data Operation records Overview View notification records Create a notification channel View, edit, and delete a notification channel Configure a custom channel Manage notification rules Login integration Approval integration SQL approval integration Bastion host integration Deployment overview Preparations before deployment Deploy ODC in single-node mode Deploy ODC in high-availability mode Deployment verification Upgrade Overview Preparations before upgrade Update single-node ODC Update high-avaliability ODC Upgrade verification Rollback after upgrade failed Tips for SQL development Explore ODC team workspaces Understanding real-time SQL diagnostics for OceanBase AP OceanBase historical database solutions ODC SQL check for automatic identification of high-risk operations Integration with ODC enterprise-level account system Manage and modify sharded databases and tables via ODC Data masking and control practices Enterprise-level control and collaboration: Safeguard every database change ODC troubleshooting process View the runtime environment and version information View web ODC logs View client ODC logs View end-to-end ODC-related logs View ODC MetaDB data Query the index status in OceanBase Database V4.x Query the index status in OceanBase Database V1.4.x to V3.2.x Collect JVM runtime information Use tcpdump to capture packets Installation of client ODC Web ODC deployment and startup Connection Information Command-line window DDL statement display Common features ODC V4.4.0 ODC V4.3.4 ODC V4.3.3 ODC V4.3.2 ODC V4.3.1 ODC V4.3.0 ODC V4.2.4
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 Developer Center
  3. V4.4.0
iconOceanBase Developer Center
V 4.4.0
  • V 4.4.2
  • V 4.4.1
  • V 4.4.0
  • V 4.3.4
  • V 4.3.3
  • V 4.3.2
  • V 4.3.1
  • V 4.3.0
  • V 4.2.4
  • V 4.2.3
  • V 4.2.2
  • V 4.2.1
  • V 4.2.0
  • V 4.1.3 and earlier

Examples of partitioning strategies

Last Updated:2026-04-07 10:00:35  Updated
share
What is on this page
Set a partitioning strategy for an OceanBase MySQL compatible mode table
Set a partitioning strategy for an OceanBase Oracle compatible mode table
References

folded

share

This topic describes how to set partition creation strategies and partition deletion strategies.

Set a partitioning strategy for an OceanBase MySQL compatible mode table

The following example describes how to set a partitioning strategy for the order table in the test_424 database of the mysql424 data source. The example also describes how to set a drop partitioning strategy for the order table.

  1. In the SQL window, execute the following statement to create the order table.

    CREATE TABLE `order` (
     `time` date NOT NULL,
     `parti_key` int(11),
     `name` varchar(120) DEFAULT NULL
    ) partition by range columns(time, parti_key)
    (partition p2023_01 values less than ('2023-01-01', 20230101),
    partition p2023_02 values less than ('2023-02-01', 20230201))
    
  2. On the Ticket tab, choose Partitioning Plan > Create Partitioning Plan.

  3. In the Create Partitioning Plan panel, click edit to edit the partitioning strategy.

  4. In the Partitioning Strategy panel, select the Creation Strategy node under Partitioning Strategy to create a partitioning strategy.

  5. Specify the number of partitions to be created.

  6. Create rules.

    As shown in the preceding figure, you can set the partitioning strategy for the time and parti_key partitioning keys of the order table.

    • time: The time partitioning key is of the DATE type, which is a time type. Therefore, you can set the Sequential Increment strategy as the partitioning strategy for this partitioning key. In this example, the creation strategy of the time partitioning key is to generate several partitions based on the current time (that is, the time when the partitioning plan task actually runs) as the starting point, with a monthly interval.

    • parti_key: The parti_key partitioning key is of the INT type. You can set the Custom strategy as the partitioning strategy. Assume that you want to generate partitions based on the current time as the starting point, with a monthly interval. To set a custom partitioning strategy, follow the steps described in the Custom Partitioning Strategy section. The expression can be generated based on the following steps:

      1. Obtain the base time for generating partitions. In this example, the current time serves as the base time. Therefore, you can directly use the now() function.

      2. Define the interval for generating partitions. In this example, partitions are to be generated with a monthly interval. To set the Create Rule, click Rule Details > Interval. Enter 1 as the fixed interval and add the interval expression to the basis expression in Step 1 to generate the next partition. The expression is now () + interval ${INTERVAL} month, where ${INTERVAL} refers to the value entered in Creation Rule > Rule Details > Interval.

      3. Generate a partitioning expression corresponding to the type of the partitioning key. The parti_key partitioning key is of the int type, but the expression generated in Step 1 is of the time type. Therefore, you need to convert it to an int type. You can first convert it to a numeric string and then convert it to an int type. The expression is: cast(date_format(now() + interval ${INTERVAL} month, '%Y%m01') as signed).

        Here are some points to note:

        • CAST(xxx AS SIGNED): converts a field to an integer.

        • DATE_FORMAT(): converts a field to a date format.

        • NOW(): returns the current date.

          Note

          In ODC, you can also use the ${LAST_PARTITION_VALUE} variable to introduce the upper limit of the partition in the current database for subsequent partition generation. For example, ${LAST_PARTITION_VALUE} + interval ${INTERVAL} month generates partitions from the upper limit of the latest partition in the database.

        • INTERVAL ${INTERVAL} MONTH: a monthly interval expression. ${INTERVAL} is a fixed usage in ODC.

        • '%Y%m01': the date format.

  7. Select a naming method.

    As shown in the preceding figure, the selected naming method is Prefix+Suffix, which consists of a fixed prefix and a suffix based on time.

    1. Fixed prefix: You can specify the prefix as you like.

    2. Suffix: You can select the upper bound of the time-type partitioning key as the suffix for naming the current partition. You can also specify the formatted output format and the incremental interval of time.

    3. After the settings are completed, you can click Test Generation to view the partition names.

  8. In the Drop Partitions section, set the time interval to pre-create the corresponding number of partitions and specify whether to rebuild indexes after the partitions are dropped.

  9. In the OK button in the lower-right corner of the Partitioning Strategy panel, to view the SQL statements generated based on the partitioning strategy.

  10. Click OK to complete the setting of the partitioning strategy.

Set a partitioning strategy for an OceanBase Oracle compatible mode table

The following example describes how to set a partitioning strategy for the order table in the OBORACLE database under the oboracle_430 data source.

  1. In the SQL window, execute the following statement to create the order table.

    CREATE TABLE "OBORACLE"."order" (
    "TIME" DATE NOT NULL ENABLE,
    "KEY" NUMBER(*,0) NOT NULL ENABLE,
    "NAME" VARCHAR2(120) DEFAULT NULL
    ) COMPRESS FOR ARCHIVE REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
    partition by range("TIME", "KEY")
    (partition "p2024_01" values less than (TO_DATE(' 2024-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'),20240101),
    partition "p2024_02" values less than (TO_DATE(' 2024-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'),20240201));
    
  2. On the Ticket tab, choose Partitioning Plan > Create Partitioning Plan.

  3. In the Create Partitioning Plan panel, click edit to edit the partitioning strategy.

  4. In the Partitioning Strategy panel, select the Partitioning Strategy > Creation Strategy checkbox to create a partitioning strategy.

  5. Specify the number of partitions to be created.

  6. Create rules.

    As shown in the preceding figure, you can set a partitioning strategy for the TIME and KEY partitioning keys of the order table.

    • TIME: This partitioning key is of the DATE type and therefore a time type. You can use Sequential Increment as the partitioning strategy for this key. In this example, the creation strategy for the TIME partitioning key is to generate several partitions starting from the current time (that is, the time when the partitioning plan task actually runs) with an interval of 1 month.

    • KEY: This partitioning key is of the NUMBER type. You can use Custom as the partitioning strategy. Assume that you want to generate partitions with an interval of 1 month starting from the current system time as the baseline. To create a custom partitioning strategy, follow the steps outlined in Create a custom partitioning strategy. The expression can be generated in the following steps:

      1. Obtain the baseline time for partition generation. In this example, the current system time is used as the baseline. You can directly use the sysdate function.

      2. Define the interval for partition generation. In this example, partitions are to be generated with an interval of 1 month. To create partitions with an interval of 1 month, set Creation Rule > Rule Details > Interval to NUMTOYMINTERVAL(1, 'MONTH') for fixed intervals, and add this to the expression in step 1 to generate the next partition. The expression will be in a datetime format, such as SYSDATE + ${INTERVAL}, where ${INTERVAL} indicates the value set in Creation Rule > Rule Details > Interval.

      3. Generate an expression for the partitioning key type. The KEY partitioning key is of the NUMBER type, but the expression generated in step 1 is in a datetime format. You need to convert it to the NUMBER type. You can first convert it to a numeric string and then convert it to the NUMBER type. The expression will be TO_CHAR(SYSDATE + ${INTERVAL}, 'YYYYMM"01"').

        Here,

        • TO_CHAR: converts a field to a character string.

        • SYSDATE: returns the current system time.

        • YYYYMM"01": the datetime format.

  7. Select a naming method.

    As shown in the preceding figure, the selected naming method is Prefix+Suffix, which consists of a fixed string prefix and a time-based suffix.

    1. Fixed prefix: You can specify this prefix as you like.

    2. Time-based suffix: You can select the upper bound of a time-type partition key as the suffix for the current partition. You can also specify the datetime format and the increment interval of the time.

    3. After you configure the preceding parameters, click Test Generation to view the partition names.

  8. In the Drop Partitions section, set the time interval to pre-create the specified number of partitions and specify whether to rebuild indexes after the partitions are dropped.

  9. In the Partitioning Strategy panel, click Preview SQL to view the SQL statement generated based on the specified partitioning strategy.

  10. Click OK.

References

  • Manage partitioning plans

  • Set partitioning strategies

Previous topic

Set partitioning strategies
Last

Next topic

SQL plan task
Next
What is on this page
Set a partitioning strategy for an OceanBase MySQL compatible mode table
Set a partitioning strategy for an OceanBase Oracle compatible mode table
References