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 - V3.2.4Enterprise Edition

    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. V3.2.4
    iconOceanBase Database
    SQL - V 3.2.4Enterprise Edition
    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

    EXPLAIN

    Last Updated:2023-10-24 09:23:03  Updated
    share
    What is on this page
    Purpose
    Syntax
    Parameters
    Examples

    folded

    share

    Purpose

    You can use this statement to interpret the execution plan for an SQL statement which can be a SELECT, DELETE, INSERT, REPLACE or UPDATE statement.

    EXPLAIN, DESCRIBE, and DESC are synonyms.

    Syntax

    /*Obtain table or column information.*/
    {EXPLAIN  DESCRIBE  DESC} table_name [column_name];
    
    /*Obtain the SQL plan.*/
    {EXPLAIN  DESCRIBE  DESC} [explain_type] dml_statement;
    
    explain_type:
        BASIC 
       OUTLINE
       EXTENDED
       EXTENDED_NOADDR
       PARTITIONS 
       FORMAT = {TRADITIONAL JSON}
    
    dml_statement:
        SELECT statement 
       DELETE statement 
       INSERT statement 
       UPDATE statement 
       MERGE statement
    

    Parameters

    Parameter Description
    table_name The table name.
    column_name The column name of the table.
    explain_type The explanation type.
    BASIC Outputs basic information about the execution plan, such as the operator ID, operator name, and name of the referenced table.
    OUTLINE Outputs execution plan information, with the outline included.
    EXTENDED Outputs extended information, including the input and output columns of each operator, the partitions of the accessed table, and the currently used filters. If the current operator references an index, the referenced index and the extracted query range are displayed in the information.
    EXTENDED_NOADDR Outputs extended information in a brief way.
    PARTITIONS Displays the partition-related information.
    TRADITIONAL JSON The output format of EXPLAIN. Valid values:
    • TRADITIONAL: presents the output in tabular format.
    • JSON: presents the output in KEY:VALUE format. The output is displayed as JSON strings, including the EXTENDED and PARTITIONS information.
    dml_statement The DML statement.

    Examples

    Create two tables respectively named tbl1 and tbl2.

    obclient>CREATE TABLE tbl1(col1 INT,col2 INT);
    Query OK, 0 rows affected
    
    obclient>CREATE TABLE tbl2(col1 INT,col2 INT);
    Query OK, 0 rows affected
    
    • Obtain the information about the tbl1 table.

      obclient> EXPLAIN tbl1;
      +-------+------------+------+-----+---------+-------+
       FIELD  TYPE        NULL  KEY  DEFAULT  EXTRA 
      +-------+------------+------+-----+---------+-------+
       COL1   NUMBER(38)  YES   NULL  NULL     NULL  
       COL2   NUMBER(38)  YES   NULL  NULL     NULL  
      +-------+------------+------+-----+---------+-------+
      2 rows in set
      
    • Obtain the information about the col2 column of the tbl2 table.

      obclient> EXPLAIN tbl2 col2;
      +-------+------------+------+-----+---------+-------+
       FIELD  TYPE        NULL  KEY  DEFAULT  EXTRA 
      +-------+------------+------+-----+---------+-------+
       COL2   NUMBER(38)  YES   NULL  NULL     NULL  
      +-------+------------+------+-----+---------+-------+
      1 row in set
      
    • Omit explain_type and return the execution plan of the SELECT statement.

      obclient> EXPLAIN SELECT * FROM tbl1,tbl2 WHERE tbl1.col2=tbl2.col2 AND tbl2.col1 > 4\G
      *************************** 1. row ***************************
      Query Plan: =======================================
      IDOPERATOR   NAMEEST. ROWSCOST   
      ---------------------------------------
      0 HASH JOIN      9801000  2442404
      1  TABLE SCANTBL210000    40790  
      2  TABLE SCANTBL1100000   38681  
      =======================================
      
      Outputs & filters:
      -------------------------------------
        0 - output([TBL1.COL1], [TBL1.COL2], [TBL2.COL1], [TBL2.COL2]), filter(nil),
            equal_conds([TBL1.COL2 = TBL2.COL2]), other_conds(nil)
        1 - output([TBL2.COL2], [TBL2.COL1]), filter([TBL2.COL1 > 4]),
            access([TBL2.COL2], [TBL2.COL1]), partitions(p0)
        2 - output([TBL1.COL2], [TBL1.COL1]), filter(nil),
            access([TBL1.COL2], [TBL1.COL1]), partitions(p0)
      
      1 row in set
      
    • Output extended information by using the EXTENDED_NOADDR keyword.

      obclient> EXPLAIN EXTENDED_NOADDR SELECT * FROM tbl1,tbl2 WHERE tbl1.col2=tbl2.col2 AND tbl2.col1 > 4\G
      *************************** 1. row ***************************
      Query Plan: =======================================
      IDOPERATOR   NAMEEST. ROWSCOST   
      ---------------------------------------
      0 HASH JOIN      9801000  2442404
      1  TABLE SCANTBL210000    40790  
      2  TABLE SCANTBL1100000   38681  
      =======================================
      
      Outputs & filters:
      -------------------------------------
        0 - output([TBL1.COL1], [TBL1.COL2], [TBL2.COL1], [TBL2.COL2]), filter(nil),
            equal_conds([TBL1.COL2 = TBL2.COL2]), other_conds(nil)
        1 - output([TBL2.COL2], [TBL2.COL1]), filter([TBL2.COL1 > 4]),
            access([TBL2.COL2], [TBL2.COL1]), partitions(p0),
            is_index_back=false, filter_before_indexback[false],
            range_key([TBL2.__pk_increment]), range(MIN ; MAX)always true
        2 - output([TBL1.COL2], [TBL1.COL1]), filter(nil),
            access([TBL1.COL2], [TBL1.COL1]), partitions(p0),
            is_index_back=false,
            range_key([TBL1.__pk_increment]), range(MIN ; MAX)always true
      
      1 row in set
      
    • Show the execution plan of the INSERT statement in TRADITIONAL format.

      obclient> EXPLAIN FORMAT=TRADITIONAL INSERT INTO TBL1 VALUES(1,1)\G
      *************************** 1. row ***************************
      Query Plan: ====================================
      IDOPERATOR   NAMEEST. ROWSCOST
      ------------------------------------
      0 INSERT         1        1   
      1  EXPRESSION    1        1   
      ====================================
      
      Outputs & filters:
      -------------------------------------
        0 - output([column_conv(BIGINT UNSIGNED,PS:(-1,-1),NOT NULL,nextval(1))], [column_conv(NUMBER,PS:(38,0),NULL,__values.COL1)], [column_conv(NUMBER,PS:(38,0),NULL,__values.COL2)]), filter(nil),
            columns([{TBL1: ({TBL1: (TBL1.__pk_increment, TBL1.COL1, TBL1.COL2)})}]), partitions(p0)
        1 - output([__values.COL1], [__values.COL2]), filter(nil)
            values({1, 1})
      
      1 row in set
      
    • Show the execution plan of the SELECT statement in JSON format.

      obclient> EXPLAIN FORMAT=JSON SELECT * FROM tbl1,tbl2 WHERE tbl1.col2=tbl2.col2 AND tbl2.col1 > 4\G
      *************************** 1. row ***************************
      Query Plan: {
        "ID":2,
        "OPERATOR":"JOIN",
        "NAME":"JOIN",
        "EST.ROWS":9800999,
        "COST":2442403,
        "output": [
          "TBL1.COL1",
          "TBL1.COL2",
          "TBL2.COL1",
          "TBL2.COL2"
        ],
        "CHILD_1": {
          "ID":0,
          "OPERATOR":"TABLE SCAN",
          "NAME":"TABLE SCAN",
          "EST.ROWS":10000,
          "COST":40789,
          "output": [
            "TBL2.COL2",
            "TBL2.COL1"
          ]
        },
        "CHILD_2": {
          "ID":1,
          "OPERATOR":"TABLE SCAN",
          "NAME":"TABLE SCAN",
          "EST.ROWS":100000,
          "COST":38680,
          "output": [
            "TBL1.COL2",
            "TBL1.COL1"
          ]
        }
      }
      1 row in set
      

    Previous topic

    COMMIT
    Last

    Next topic

    FLASHBACK TABLE BEFORE DROP
    Next
    What is on this page
    Purpose
    Syntax
    Parameters
    Examples