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.2.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.2.5
    iconOceanBase Database
    SQL - V 4.2.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

    Drop a partition

    Last Updated:2026-04-09 09:38:52  Updated
    share
    What is on this page
    Support for dropping partitions from partitioned tables
    Drop a partition
    Drop a subpartition

    folded

    share

    You can drop partitions from a partitioned table as needed.

    Support for dropping partitions from partitioned tables

    The following table describes the support for dropping partitions from partitioned and subpartitioned tables in MySQL mode of OceanBase Database.

    Partitioned table type Partitioning type Drop partitions Drop subpartitions
    Partitioned table
    • RANGE
    • RANGE COLUMNS
    • LIST
    • LIST COLUMNS
    Supported -
    Partitioned table
    • HASH
    • KEY
    Not supported -
    Subpartitioned table
    • RANGE-RANGE
    • RANGE-RANGE COLUMNS
    • RANGE-LIST
    • RANGE-LIST COLUMNS
    Supported Supported
    Subpartitioned table
    • RANGE-HASH
    • RANGE-KEY
    Supported Not supported
    Subpartitioned table
    • RANGE COLUMNS-RANGE
    • RANGE COLUMNS-RANGE COLUMNS
    • RANGE COLUMNS-LIST
    • RANGE COLUMNS-LIST COLUMNS
    Supported Supported
    Subpartitioned table
    • RANGE COLUMNS-HASH
    • RANGE COLUMNS-KEY
    Supported Not supported
    Subpartitioned table
    • LIST-RANGE
    • LIST-RANGE COLUMNS
    • LIST-LIST
    • LIST-LIST COLUMNS
    Supported Supported
    Subpartitioned table
    • LIST-HASH
    • LIST-KEY
    Supported Not supported
    Subpartitioned table
    • LIST COLUMNS-RANGE
    • LIST COLUMNS-RANGE COLUMNS
    • LIST COLUMNS-LIST
    • LIST COLUMNS-LIST COLUMNS
    Supported Supported
    Subpartitioned table
    • LIST COLUMNS-HASH
    • LIST COLUMNS-KEY
    Supported Not supported
    Subpartitioned table
    • HASH-RANGE
    • HASH-RANGE COLUMNS
    • HASH-LIST
    • HASH-LIST COLUMNS
    Not supported Supported
    Subpartitioned table
    • HASH-HASH
    • HASH-KEY
    Not supported Not supported
    Subpartitioned table
    • KEY-RANGE
    • KEY-RANGE COLUMNS
    • KEY-LIST
    • KEY-LIST COLUMNS
    Not supported Supported
    Subpartitioned table
    • KEY-HASH
    • KEY-KEY
    Not supported Not supported

    Drop a partition

    You can drop a partition from a RANGE-, RANGE COLUMNS-, LIST, or LIST COLUMNS-partitioned table. You cannot drop partitions from HASH- or KEY-partitioned tables.

    The SQL syntax for dropping a partition is as follows:

    ALTER TABLE table_name DROP PARTITION partition_name[, partition_name ...];
    

    Note

    • You can drop multiple partitions at a time, but you cannot drop all partitions in a table.

    • Before you drop a partition, ensure that no active transactions or queries exist in this partition. Otherwise, SQL statement errors or exceptions may occur. You can query the oceanbase.GV$OB_TRANSACTION_PARTICIPANTS view for the context status of unfinished transactions in the sys tenant.

    • When you drop a partition, the data in the partition is also dropped. If you want to drop only the data, use the TRUNCATE statement.

    • When you drop a partition from a subpartitioned table, its definition, data, and subpartitions are also dropped.

    Here are some examples:

    • Create a partitioned table named tbl1_r and drop the M202011 and M202012 partitions from it.

      obclient> CREATE TABLE tbl1_r (log_id BIGINT NOT NULL,log_value VARCHAR(50),log_date TIMESTAMP NOT NULL)
             PARTITION BY RANGE(UNIX_TIMESTAMP(log_date)) 
              (PARTITION M202001 VALUES LESS THAN(UNIX_TIMESTAMP('2020/02/01'))
             , PARTITION M202002 VALUES LESS THAN(UNIX_TIMESTAMP('2020/03/01'))
             , PARTITION M202003 VALUES LESS THAN(UNIX_TIMESTAMP('2020/04/01'))
             , PARTITION M202004 VALUES LESS THAN(UNIX_TIMESTAMP('2020/05/01'))
             , PARTITION M202005 VALUES LESS THAN(UNIX_TIMESTAMP('2020/06/01'))
             , PARTITION M202006 VALUES LESS THAN(UNIX_TIMESTAMP('2020/07/01'))
             , PARTITION M202007 VALUES LESS THAN(UNIX_TIMESTAMP('2020/08/01'))
             , PARTITION M202008 VALUES LESS THAN(UNIX_TIMESTAMP('2020/09/01'))
             , PARTITION M202009 VALUES LESS THAN(UNIX_TIMESTAMP('2020/10/01'))
             , PARTITION M202010 VALUES LESS THAN(UNIX_TIMESTAMP('2020/11/01'))
             , PARTITION M202011 VALUES LESS THAN(UNIX_TIMESTAMP('2020/12/01'))
             , PARTITION M202012 VALUES LESS THAN(UNIX_TIMESTAMP('2021/01/01'))
              );
      Query OK, 0 rows affected
      
      obclient> ALTER TABLE tbl1_r DROP PARTITION M202011,M202012;
      Query OK, 0 rows affected
      
    • Create a template-based RANGE COLUMNS-RANGE COLUMNS-subpartitioned table named t_m_rcrc and drop the p1 and p2 partitions from it.

      obclient> CREATE TABLE t_m_rcrc(col1 INT,col2 INT) 
             PARTITION BY RANGE COLUMNS(col1)
             SUBPARTITION BY RANGE COLUMNS(col2)
             SUBPARTITION TEMPLATE 
              (SUBPARTITION mp0 VALUES LESS THAN(1000),
               SUBPARTITION mp1 VALUES LESS THAN(2000),
               SUBPARTITION mp2 VALUES LESS THAN(3000)
              )
              (PARTITION p0 VALUES LESS THAN(100),
               PARTITION p1 VALUES LESS THAN(200),
               PARTITION p2 VALUES LESS THAN(300)
              ); 
      Query OK, 0 rows affected
      
      obclient> ALTER TABLE t_m_rcrc DROP PARTITION p1,p2;
      Query OK, 0 rows affected
      
    • Create a RANGE-RANGE-subpartitioned table named t_f_rr and drop the p1 partition from it.

      obclient> CREATE TABLE t_f_rr(col1 INT,col2 TIMESTAMP) 
             PARTITION BY RANGE(col1)
             SUBPARTITION BY RANGE(UNIX_TIMESTAMP(col2))
              (PARTITION p0 VALUES LESS THAN(100)
                 (SUBPARTITION sp0 VALUES LESS THAN(UNIX_TIMESTAMP('2021/04/01')),
                  SUBPARTITION sp1 VALUES LESS THAN(UNIX_TIMESTAMP('2021/07/01')),
                  SUBPARTITION sp2 VALUES LESS THAN(UNIX_TIMESTAMP('2021/10/01')),
                  SUBPARTITION sp3 VALUES LESS THAN(UNIX_TIMESTAMP('2022/01/01'))
                 ),
               PARTITION p1 VALUES LESS THAN(200)
                 (SUBPARTITION sp4 VALUES LESS THAN(UNIX_TIMESTAMP('2021/04/01')),
                  SUBPARTITION sp5 VALUES LESS THAN(UNIX_TIMESTAMP('2021/07/01')),
                  SUBPARTITION sp6 VALUES LESS THAN(UNIX_TIMESTAMP('2021/10/01')),
                  SUBPARTITION sp7 VALUES LESS THAN(UNIX_TIMESTAMP('2022/01/01'))
                  )
               );
      Query OK, 0 rows affected
      
      obclient> ALTER TABLE t_f_rr DROP PARTITION p1;
      Query OK, 0 rows affected
      

    Drop a subpartition

    The SQL syntax for dropping a subpartition is as follows:

    ALTER TABLE table_name DROP SUBPARTITION subpartition_name[, subpartition_name ...];
    

    Note

    • Before you drop a subpartition from a subpartitioned table, ensure that no active transactions or queries exist in this subpartition. Otherwise, SQL statement errors or exceptions may occur. You can query the oceanbase.GV$OB_TRANSACTION_PARTICIPANTS view for the context status of unfinished transactions in the sys tenant.

    • If you drop a subpartition, its definition and data are also dropped.

    • If you want to drop multiple subpartitions at a time, they must belong to the same partition.

    Here is an example of creating a non-template-based RANGE-RANGE-partitioned table named t_f_rr and dropping the sp6 and sp7 subpartitions from it:

    obclient> CREATE TABLE t_f_rr(col1 INT,col2 TIMESTAMP) 
           PARTITION BY RANGE(col1)
           SUBPARTITION BY RANGE(UNIX_TIMESTAMP(col2))
            (PARTITION p0 VALUES LESS THAN(100)
               (SUBPARTITION sp0 VALUES LESS THAN(UNIX_TIMESTAMP('2021/04/01')),
                SUBPARTITION sp1 VALUES LESS THAN(UNIX_TIMESTAMP('2021/07/01')),
                SUBPARTITION sp2 VALUES LESS THAN(UNIX_TIMESTAMP('2021/10/01')),
                SUBPARTITION sp3 VALUES LESS THAN(UNIX_TIMESTAMP('2022/01/01'))
               ),
             PARTITION p1 VALUES LESS THAN(200)
               (SUBPARTITION sp4 VALUES LESS THAN(UNIX_TIMESTAMP('2021/04/01')),
                SUBPARTITION sp5 VALUES LESS THAN(UNIX_TIMESTAMP('2021/07/01')),
                SUBPARTITION sp6 VALUES LESS THAN(UNIX_TIMESTAMP('2021/10/01')),
                SUBPARTITION sp7 VALUES LESS THAN(UNIX_TIMESTAMP('2022/01/01'))
                )
             );
    Query OK, 0 rows affected
    
    obclient> ALTER TABLE t_f_rr DROP SUBPARTITION sp6,sp7;
    Query OK, 0 rows affected
    

    Previous topic

    Add a partition
    Last

    Next topic

    Truncate a partition
    Next
    What is on this page
    Support for dropping partitions from partitioned tables
    Drop a partition
    Drop a subpartition