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

    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.0
    iconOceanBase Database
    SQL - V 4.2.0
    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

    SYS_CONNECT_BY_PATH

    Last Updated:2023-10-31 11:17:12  Updated
    share
    What is on this page
    Purpose
    Syntax
    Parameters
    Return type
    Examples

    folded

    share

    Purpose

    SYS_CONNECT_BY_PATH() returns the paths of column values from the root to nodes. The column values of each row returned by the CONNECT BY condition are separated with the specified delimiter.

    Note

    This function is valid only in hierarchical queries.

    Syntax

    SYS_CONNECT_BY_PATH(column,'char')
    

    Parameters

    Parameter Description
    column The column whose values need to be returned. It can be of the CHAR, VARCHAR2, NCHAR, or NVARCHAR2 data type.
    char The delimiter. It can be of the CHAR, VARCHAR2, NCHAR, or NVARCHAR2 data type.

    Return type

    The return type is VARCHAR2.

    Examples

    Create a table named tbl1 and insert test data into it. The ABC value of the name column is the root value, and other values are node values. Query the paths from the root value ABC to all other values of the name column.

    obclient> CREATE TABLE tbl1(z_id INT,name VARCHAR2(20),n_id INT);
    Query OK, 0 rows affected
    
    obclient> INSERT INTO tbl1 VALUES(0,'ABC',''),
        ->                (1,'An',0),(2,'Bn',0),(3,'Cn',0),
        ->                (4,'A1',1),(5,'B1',2),(6,'C1',3),
        ->                (7,'C2',6),(8,'A2',4),(9,'B2',5),
        ->                (10,'A3',8),(11,'A4',10),(12,'B3',9);
    Query OK, 13 rows affected
    Records: 13  Duplicates: 0  Warnings: 0
    
    obclient> COMMIT;
    Query OK, 0 rows affected
    
    obclient> SELECT * FROM tbl1;
    +------+------+------+
    | Z_ID | NAME | N_ID |
    +------+------+------+
    |    0 | ABC  | NULL |
    |    1 | An   |    0 |
    |    2 | Bn   |    0 |
    |    3 | Cn   |    0 |
    |    4 | A1   |    1 |
    |    5 | B1   |    2 |
    |    6 | C1   |    3 |
    |    7 | C2   |    6 |
    |    8 | A2   |    4 |
    |    9 | B2   |    5 |
    |   10 | A3   |    8 |
    |   11 | A4   |   10 |
    |   12 | B3   |    9 |
    +------+------+------+
    13 rows in set
    
    obclient> SELECT z_id,name,n_id,SYS_CONNECT_BY_PATH(name, '/') "Path"
              FROM tbl1
              START WITH n_id IS NULL
              CONNECT BY PRIOR n_id = z_id
              ORDER BY z_id;
    +------+------+------+---------------------+
    | Z_ID | NAME | N_ID | Path                |
    +------+------+------+---------------------+
    |    0 | ABC  | NULL | /ABC                |
    |    1 | An   |    0 | /ABC/An             |
    |    2 | Bn   |    0 | /ABC/Bn             |
    |    3 | Cn   |    0 | /ABC/Cn             |
    |    4 | A1   |    1 | /ABC/An/A1          |
    |    5 | B1   |    2 | /ABC/Bn/B1          |
    |    6 | C1   |    3 | /ABC/Cn/C1          |
    |    7 | C2   |    6 | /ABC/Cn/C1/C2       |
    |    8 | A2   |    4 | /ABC/An/A1/A2       |
    |    9 | B2   |    5 | /ABC/Bn/B1/B2       |
    |   10 | A3   |    8 | /ABC/An/A1/A2/A3    |
    |   11 | A4   |   10 | /ABC/An/A1/A2/A3/A4 |
    |   12 | B3   |    9 | /ABC/Bn/B1/B2/B3    |
    +------+------+------+---------------------+
    13 rows in set
    

    Previous topic

    OB_VERSION
    Last

    Next topic

    Overview
    Next
    What is on this page
    Purpose
    Syntax
    Parameters
    Return type
    Examples