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

    CREATE TYPE BODY

    Last Updated:2023-10-31 11:17:11  Updated
    share
    What is on this page
    Prerequisites
    Syntax
    Semantics
    Examples

    folded

    share

    You can use the CREATE TYPE BODY statement to define or implement the member methods in a type specification created by using the CREATE TYPE statement.

    For a method not specified in the type specification of call_spec, you must specify the corresponding method body in the type body.

    Applicability

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

    Prerequisites

    In the CREATE TYPE statement used to create an abstract data type (ADT), each member declaration must have a corresponding construct in the CREATE TYPE or CREATE TYPE BODY definition.

    To create or replace a type body in your own schema, you must have the CREATE TYPE or CREATE ANY TYPE system privilege. To create a type in the schema of other users, you must have the CREATE ANY TYPE system privilege. To replace a type in the schema of other users, you must have the DROP ANY TYPE system privilege.

    Syntax

    Note

    This topic describes the syntax of some important syntax nodes only.

    • The syntax of create_type_body_stmt is as follows:

      create_type_body_stmt

    • The syntax of plsql_type_body_source is as follows:

      plsql_type_body_source

    • The syntax of plsql_type_body_decl_list_semicolon is as follows:

      3plsql_type_body_decl_list_semicolon

    • The syntax of plsql_type_body_decl_list is as follows:

      4plsql_type_body_decl_list

    • The syntax of proc_or_func_def_in_type is as follows:

      8proc_or_func_def_in_type

    Semantics

    Syntax
    Keyword or syntax node
    Description
    create_type_body_stmt OR REPLACE Re-creates this type body (if any) and recompiles it. Before the type body is redefined, users granted the access privilege can still access this type body without the need to obtain the access privilege again. You can use this clause to add the definition of a member subprogram to the specification defined by using ALTER TYPE ... REPLACE.
    plsql_type_body_source pl_schema_name The name of the schema that contains the type body. The default value is your own schema.
    plsql_type_body_source TYPE The name of the ADT.
    subprog_decl_in_type subprog_decl_in_type The type of the feature or stored procedure that is associated with the type specification. You must define in the type specification a corresponding method name and a parameter list for each stored procedure or function. You must also specify a return type for functions.
    proc_or_func_def_in_type proc_or_func_def_in_type The definition of a stored procedure or function.

    Examples

    obclient> CREATE TYPE demo_typ2 AS OBJECT (
         a1 NUMBER,
         MEMBER FUNCTION get_square RETURN NUMBER
       );
    /
    
    obclient> CREATE OR REPLACE TYPE BODY demo_typ2 IS
         MEMBER FUNCTION get_square RETURN NUMBER IS
         BEGIN
            RETURN a1;
        END;
      END;
    /
    

    Previous topic

    CREATE TYPE
    Last

    Next topic

    DROP FUNCTION
    Next
    What is on this page
    Prerequisites
    Syntax
    Semantics
    Examples