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.2.2

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & CertificationTicket
    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.2
    iconOceanBase Database
    SQL - V 4.2.2
    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

    DELETE

    Last Updated:2026-04-15 08:27:15  Updated
    share
    What is on this page
    Purpose
    Syntax
    Parameters
    Examples

    folded

    share

    Purpose

    You can use this statement to delete rows that meet the conditions from one or more tables.

    Direct DELETE operations on subqueries are not supported for either a single table or multiple tables. For example, DELETE FROM (SELECT * FROM t1); cannot be executed.

    Syntax

    Single-Table-Delete Syntax:
        DELETE [hint_options] FROM table_name
        [PARTITION (partition_name,...)]
        [WHERE where_condition]
        [ORDER BY order_expression_list]
        [LIMIT row_count]
    
    Multiple-Table-Delete Syntax:
        DELETE [hint_options] table_name[.*] [, table_name[.*]] ...
        FROM table_references
        [WHERE where_condition]
    Or:
        DELETE [hint_options] FROM table_name[.*] [, table_name[.*]] ...
        USING table_references
        [WHERE where_condition]
    
    where_condition:
        expression
    
    order_expression_list:
        order_expression [, order_expression ...]
    
    order_expression:
        expression [ASC | DESC]
    
    limit_row_count:
        INT_VALUE
    
    table_references:
        {table_name | joined_table | table_subquery | select_with_parents} [, ...]
    
    

    Parameters

    Parameter
    Description
    hint_options Specifies the hint options.
    table_name The name of the table from which rows are to be deleted.
    partition_name The name of a target partition in the table from which rows are to be deleted.
    where_condition The condition that the rows to be deleted must meet.
    order_expression_list The list of sort keys for the table from which rows are to be deleted.
    row_count The number of rows to be deleted. The specified value must be an integer.
    table_references The sequence of tables to be selected when you delete rows from two or more tables.

    Examples

    Sample tables and their data are defined as follows:

    obclient> CREATE TABLE t1(c1 INT PRIMARY KEY, c2 INT);
    Query OK, 0 rows affected
    obclient> SELECT * FROM t1;
    +----+------+
    | c1 | c2   |
    +----+------+
    |  1 |    1 |
    |  2 |    2 |
    |  3 |    3 |
    |  4 |    4 |
    +----+------+
    4 rows in set
    
    obclient> CREATE TABLE t2(c1 INT PRIMARY KEY, c2 INT) PARTITION BY KEY(c1) PARTITIONS 4;
    Query OK, 0 rows affected
    obclient> SELECT * FROM t2;
    +----+------+
    | c1 | c2   |
    +----+------+
    |  5 |    5 |
    |  1 |    1 |
    |  2 |    2 |
    |  3 |    3 |
    +----+------+
    4 rows in set
    
    • Single-table delete: Delete the row where c1 = 2. The c1 column is the primary key column of the t1 table.

      obclient> DELETE FROM t1 WHERE c1 = 2;
      Query OK, 1 row affected (0.02 sec)
      
      obclient> SELECT * FROM t1;
      +----+------+
      | c1 | c2   |
      +----+------+
      |  1 |    1 |
      |  3 |    3 |
      |  4 |    4 |
      +----+------+
      3 rows in set
      
    • Single-table delete: Delete the first row from the t1 table after its rows are sorted by the c2 column.

      obclient> DELETE FROM t1 ORDER BY c2 LIMIT 1;
      Query OK, 1 row affected
      
      obclient> SELECT * FROM t1;
      +----+------+
      | c1 | c2   |
      +----+------+
      |  2 |    2 |
      |  3 |    3 |
      |  4 |    4 |
      +----+------+
      3 rows in set
      
    • Single-table delete: Delete rows in the p2 partition from the t2 table.

      obclient> DELETE FROM t2 PARTITION(p2);
      Query OK, 3 rows affected
      
      obclient> SELECT * FROM t2;
      +----+------+
      | c1 | c2   |
      +----+------+
      |  5 |    5 |
      +----+------+
      1 row in set
      
    • Multi-table delete: Delete rows where t1.c1 = t2.c1 from tables t1 and t2.

      obclient> DELETE t1, t2 FROM t1, t2 WHERE t1.c1 = t2.c1;
      Query OK, 3 rows affected
      
      obclient> SELECT * FROM t1;
      +----+------+
      | c1 | c2   |
      +----+------+
      |  4 |    4 |
      +----+------+
      1 row in set
      
      obclient> SELECT * FROM t2;
      +----+------+
      | c1 | c2   |
      +----+------+
      |  5 |    5 |
      +----+------+
      1 row in set
      
    • Multi-table delete: Delete rows where t1.c1 = t2.c1 from tables t1 and t2.

      obclient> DELETE FROM t1, t2 USING t1,t2 WHERE t1.c1 = t2.c1;
      Query OK, 6 rows affected
      
      obclient> SELECT * FROM t1;
      +----+------+
      | c1 | c2   |
      +----+------+
      |  4 |    4 |
      +----+------+
      1 row in set
      
      obclient> SELECT * FROM t2;
      +----+------+
      | c1 | c2   |
      +----+------+
      |  5 |    5 |
      +----+------+
      1 row in set
      
    • Multi-table delete: Delete rows where t1.c1 = t2.c1 from the p2 partition in the t2 table.

      obclient> DELETE t2 FROM t1,t2 PARTITION(p2) WHERE t1.c1 = t2.c1;
      Query OK, 3 rows affected
      
      obclient> select * from t2;
      +----+------+
      | c1 | c2   |
      +----+------+
      |  5 |    5 |
      +----+------+
      1 row in set
      
    • Delete rows from an updatable view named v.

      obclient> CREATE VIEW v AS SELECT * FROM t1;
      Query OK, 0 rows affected
      
      obclient> DELETE FROM v WHERE v.c1 = 1;
      Query OK, 1 row affected
      
      obclient> SELECT * FROM v;
      +----+------+
      | c1 | c2   |
      +----+------+
      |  2 |    2 |
      |  3 |    3 |
      |  4 |    4 |
      +----+------+
      3 rows in set
      

    Previous topic

    DROP DATABASE LINK
    Last

    Next topic

    DESCRIBE
    Next
    What is on this page
    Purpose
    Syntax
    Parameters
    Examples