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

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogWhite PaperLive 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.4.2
    iconOceanBase Database
    SQL - V 4.4.2
    Databases
    • OceanBase Database
    • OceanBase Cloud
    • OceanBase Tugraph
    • Interactive Tutorials
    • OceanBase Best Practices
    Tools
    • OceanBase Cloud Platform
    • OceanBase Migration Service
    • OceanBase Developer Center
    • OceanBase Migration Assessment
    • OceanBase Admin Tool
    • OceanBase Loader and Dumper
    • OceanBase Deployer
    • Kubernetes operator for OceanBase
    • OceanBase Diagnostic Tool
    • OceanBase Binlog Service
    Connectors and Middleware
    • OceanBase Database Proxy
    • Embedded SQL in C for OceanBase
    • OceanBase Call Interface
    • OceanBase Connector/C
    • OceanBase Connector/J
    • OceanBase Connector/ODBC
    • OceanBase Connector/NET
    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

    PARTITIONID pseudo-column

    Last Updated:2026-04-02 06:23:58  Updated
    Share
    What is on this page
    Basic syntax
    SELECT operation
    UPDATE operation
    INSERT operation
    Limitations
    Limitations on column names conflicting with pseudo-column fields
    Limitations on table types
    Feature switch

    folded

    Share

    Note

    This feature is available starting from V4.3.5 BP2.

    The PARTITIONID pseudo-column provides the ability to retrieve the partition ID of each row of data. The value of the PARTITIONID pseudo-column is directly filled in by the tablescan operator when reading raw data, and it is not stored. This topic describes how to use the PARTITIONID pseudo-column.

    Depending on the partition level and functionality, the following six pseudo-columns are introduced:

    Column name
    Type
    Description
    __ob_partition_id int partition_id, the ID of the partition corresponding to the row of data.
    __ob_partition_index int partition_index, the index of the partition corresponding to the row of data.
    __ob_partition_name varchar partition_name, the name of the partition corresponding to the row of data.
    __ob_sub_partition_id int sub_partition_id, the ID of the sub_partition corresponding to the row of data.
    __ob_sub_partition_index int sub_partition_index, the index of the sub_partition corresponding to the row of data.
    __ob_sub_partition_name varchar sub_partition_name, the name of the sub_partition corresponding to the row of data.

    Basic syntax

    SELECT operation

    Here is an example:

    select c1,__ob_partition_id from t1;
    

    UPDATE operation

    You cannot modify the partitionid pseudo-column. You can use it in the WHERE clause.

    Here is an example:

    UPDATE t1 SET c1=c1 WHERE __ob_partition_index=2;
    

    INSERT operation

    The partitionid pseudo-column cannot be specified in the column list of an INSERT statement.

    Limitations

    Limitations on column names conflicting with pseudo-column fields

    • In a SELECT statement: If a table already contains the pseudo-column names before upgrading to a version that supports partitionid, the query will return the actual data of the column. If the table does not contain the pseudo-column names, the query will return the values of the pseudo-columns.
    • In a CREATE TABLE statement: You cannot create a table with a column name that conflicts with the pseudo-column names. Otherwise, an error OB_ERR_COLUMN_DUPLICATE is returned.
      • This applies to statements like create table tt1 as select c1,__ob_partition_id from t1; in MySQL-compatible mode.
    • When dropping a column: If the table already contains the pseudo-column names, you can drop the column. Otherwise, an error OB_ERR_BAD_FIELD_ERROR is returned.
    • When adding a column: You cannot directly add a partitionid pseudo-column that conflicts with existing columns. Otherwise, an error OB_ERR_COLUMN_DUPLICATE is returned.
    • When renaming a column: You can only rename a column that conflicts with the pseudo-column names to a different name. Otherwise, an error OB_ERR_COLUMN_DUPLICATE is returned.

    Limitations on table types

    You can only query these pseudo-columns from user tables and user views that include the pseudo-column names in their definitions.

    Feature switch

    The PARTITIONID pseudo-column occupies six column names: __ob_partition_id, __ob_partition_index, __ob_partition_name, __ob_sub_partition_id, __ob_sub_partition_index, and __ob_sub_partition_name. This prevents you from creating tables that include these column names.

    To resolve this issue, you can disable the PARTITIONID pseudo-column feature by setting the parameter _enable_pseudo_partition_id to false. This allows you to use the column names to create tables as needed.

    Here is an example:

    Notice

    After you disable the partitionid pseudo-column feature in the sys tenant, you must execute the ALTER SYSTEM flush plan cache; statement in the current tenant to manually clear the plan cache.

    ALTER SYSTEM SET _enable_pseudo_partition_id = false;
    

    Previous topic

    Overview
    Last

    Next topic

    Pseudo columns of sequences
    Next
    What is on this page
    Basic syntax
    SELECT operation
    UPDATE operation
    INSERT operation
    Limitations
    Limitations on column names conflicting with pseudo-column fields
    Limitations on table types
    Feature switch