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

    Delete data

    Last Updated:2026-04-09 09:38:52  Updated
    share
    What is on this page
    Prerequisites
    Use the DELETE statement to delete data
    Delete part of the data
    Delete all data
    Use the TRUNCATE TABLE statement to empty a table
    References

    folded

    share

    After you insert data into a table, you can use the DELETE statement or other statements to delete records from the table. This topic describes how to use related statements.

    Prerequisites

    Before you delete data from a table, make sure that:

    • You have connected to a MySQL tenant of OceanBase Database. For more information about how to connect to OceanBase Database, see Connection methods.

      Note

      You can query the oceanbase.DBA_OB_TENANTS view in the sys tenant to confirm the mode of the tenant to which you have logged in.

    • You have the DELETE privilege on the target table. To use the TRUNCATE TABLE statement to clear the data in a table, you must also have the CREATE privilege on the table. For more information about how to view your privileges, see View user privileges. If you do not have the required privilege, contact the administrator to obtain the privilege. For more information, see Grant direct privileges.

    Use the DELETE statement to delete data

    Generally, the DELETE statement is used to delete part of the data or all data from a table.

    Note

    Besides the DELETE statement, you can also use the REPLACE INTO statement to delete data. For more information about the REPLACE INTO statement, see Replace data.

    The syntax is as follows:

    DELETE FROM table_name [ WHERE condition ];
    
    Parameter Required Description
    table_name Yes The table from which data is to be deleted.
    [ WHERE condition ] No The condition for deleting data. If no condition is specified, all data in the table is deleted.

    Delete part of the data

    You can add a WHERE condition to the DELETE statement to delete the data that meets the condition from a table.

    For example, delete all rows that meet the value = 10004 condition from the t_insert table.

    obclient [test]> DELETE FROM t_insert WHERE value = 10004;
    Query OK, 1 row affected
    

    Delete all data

    If a table contains a small amount of data, you can directly use the DELETE statement to delete all rows.

    Here are some examples:

    • Delete all rows from the t_insert table.

      obclient [test]> DELETE FROM t_insert;
      Query OK, 3 row affected
      

      For a table that contains millions of records, deleting all the records at a time may result in performance issues. We recommend that you delete the data in batches by using the WHERE condition, or use the TRUNCATE TABLE statement to empty a table.

    • Filter the data in the value column of the t_insert table. Execute multiple statements to respectively delete the data that meets the value < 10000, value < 20000, and value < 30000 conditions in batches.

      obclient [test]> DELETE FROM t_insert WHERE value < 100000;
      
      obclient [test]> DELETE FROM t_insert WHERE value < 200000;
      
      obclient [test]> DELETE FROM t_insert WHERE value < 300000;
      

    Use the TRUNCATE TABLE statement to empty a table

    The TRUNCATE TABLE statement clears a table but retains its schema, including the partitions defined for the table. Logically, this statement is equivalent to the DELETE statement that is used to delete all rows.

    The syntax of the TRUNCATE TABLE statement is as follows:

    TRUNCATE [TABLE] table_name;
    

    For example, use the TRUNCATE TABLE statement to empty the t_insert table.

    obclient [test]> TRUNCATE TABLE t_insert;
    

    For more information about the TRUNCATE TABLE statement, see TRUNCATE TABLE.

    References

    • Insert data

    • Update data

    • Replace data

    Previous topic

    Update data
    Last

    Next topic

    Replace data
    Next
    What is on this page
    Prerequisites
    Use the DELETE statement to delete data
    Delete part of the data
    Delete all data
    Use the TRUNCATE TABLE statement to empty a table
    References