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.3.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.3.0
    iconOceanBase Database
    SQL - V 4.3.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

    DELETE method

    Last Updated:2026-04-15 08:30:01  Updated
    share
    What is on this page
    share

    You can use the DELETE method to delete elements from a collection.

    Applicability

    This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.

    Considerations for DELETE are as follows:

    • The DELETE method can delete all elements of any types from a collection.

      The DELETE operation will immediately release the memory space allocated to the deleted elements.

    • For associative arrays or nested tables (except variable-size arrays, or varrays):

      • DELETE(n): deletes the element whose index is n. If the element does not exist, DELETE does not take effect.
      • DELETE(m,n): deletes elements whose index is in the range of m to n if both m and n exist and m is not greater than n. Otherwise, DELETE does not take effect.

    PL retains placeholders for the elements deleted by these two DELETE operations. Therefore, the deleted element is still counted in the collection size. You can assign a valid value to the deleted element to restore it.

    Here is an example:

    obclient> CREATE OR REPLACE TYPE nested_type IS TABLE OF VARCHAR(20);/
    Query OK, 0 rows affected
    
    obclient> CREATE OR REPLACE PROCEDURE print_t (t nested_type) AUTHID DEFINER IS
      i  NUMBER;
    BEGIN
      i := t.FIRST;
    
      IF i IS NULL THEN
        DBMS_OUTPUT.PUT_LINE('t is empty');
      ELSE
        WHILE i IS NOT NULL LOOP
          DBMS_OUTPUT.PUT('t.(' || i || ') = ');
          DBMS_OUTPUT.PUT_LINE(NVL(TO_CHAR(t(i)), 'NULL'));
          i := t.NEXT(i);
        END LOOP;
      END IF;
    
      DBMS_OUTPUT.PUT_LINE('---');
    END print_t;
    /
    Query OK, 0 rows affected
    
    obclient> DECLARE
      t nested_type:= nested_type('A', 'B', 'C', 'D', 'E', 'F');
    BEGIN
      print_t(t);
    
      t.DELETE(3);     -- Delete the third element.
      print_t(t);
    
      t(3) := 'cc';    -- Restore the third element.
      print_t(t);
    
      t.DELETE(2, 4);  -- Delete a series of elements.
      print_t(t);
    
      t(3) := 'cccc';    -- Restore the third element.
      print_t(t);
    
      t.DELETE;        -- Delete all elements.
      print_t(t);
    END;
    /
    Query OK, 0 rows affected
    
    t.(1) = A
    t.(2) = B
    t.(3) = C
    t.(4) = D
    t.(5) = E
    t.(6) = F
    ---
    t.(1) = A
    t.(2) = B
    t.(4) = D
    t.(5) = E
    t.(6) = F
    ---
    t.(1) = A
    t.(2) = B
    t.(3) = cc
    t.(4) = D
    t.(5) = E
    t.(6) = F
    ---
    t.(1) = A
    t.(5) = E
    t.(6) = F
    ---
    t.(1) = A
    t.(3) = cccc
    t.(5) = E
    t.(6) = F
    ---
    t is empty
    ---
    

    The preceding example declares a nested table variable, initializes and assigns values to six elements, and performs the following operations on the elements:

    1. Delete the third element and then restore it.

    2. Delete a series of elements and then restore one of them.

    3. Delete all elements.

    The restored elements occupy the same memory space as before they are deleted. The print_nt stored procedure outputs the nested table variable after initialization and after each DELETE operation.

    Previous topic

    Overview
    Last

    Next topic

    TRIM method
    Next