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.0.0Enterprise Edition

  • Overview
    • Overview
    • System architecture
    • Compatibility with MySQL
    • Compatibility with Oracle
      • Overview
      • SQL data types
      • Built-in functions
      • System views
    • Limits
  • Get Started
    • Quick start with OceanBase Database
    • Hands on for OceanBase SQL
      • Usage notes
      • Basic SQL operations (MySQL mode)
      • Basic SQL operations (Oracle mode)
    • Build applications (MySQL Mode)
      • Connect Python applications to OceanBase Database
      • Connect Java applications to OceanBase Database
      • Connect C applications to OceanBase Database
    • Build applications(Oracle Mode)
      • Connect Python applications to OceanBase Database
      • Connect Java applications to OceanBase Database
      • Connect C applications to OceanBase Database
    • Experience OceanBase advanced features
      • Experience scalable OLTP
        • Run the TPC-C benchmark in OceanBase Database
        • Experience the hot row update capability of OceanBase Database
      • Experience operational OLAP
      • Experience parallel import and data compression
      • Experience the multitenancy feature
  • Develop
    • Develop (MySQL Mode)
      • Connect to Oceanbase Database with client
        • Overview
        • Connect to an OceanBase Database tenant by using a MySQL client
        • Connect to an OceanBase Database tenant by using OBClient
        • Connect to OceanBase Database by using ODC
        • Java application
          • OceanBase Connector/J
          • Java APIs
          • Connect Java applications to OceanBase Database
        • C application
          • OceanBase Connector/C
          • C API functions
          • Connect C applications to OceanBase Database
        • Python applications
        • SpringBoot connection example
        • SpringBatch connection example
        • Example of Database connection pool configuration
          • Overview of database connection pool configuration
          • Example of configuring a Tomcat connection pool
          • Example of configuring a C3P0 connection pool
          • Example of configuring a Proxool connection pool
          • Example of configuring a HiKariCP connection pool
          • Example of configuring a DBCP connection pool
          • CommonPool configuration example
          • Example of configuring a JDBC connection pool
        • SpringJDBC connection example
        • SpringJPA connection example
        • Hibernate connection example
        • MyBatis connection example
      • Create and manage database objects
        • About DDL statements
        • View the currently connected database
        • Change the password of a user
        • Data type
          • General data types
          • Unsupported data types
        • Create and manage tables
          • About tables
          • Create a table
          • About auto-increment columns
          • About types of column constraints
          • About table structure modification
          • About table clearing
          • About table dropping
          • Flash back a dropped table
          • About table privileges
        • Create and manage partition tables
          • About partitioned tables
          • Create a partitioned table
          • Manage a partitioned table
          • Create a subpartitioned table
          • Manage a subpartitioned table
          • Partition routing
          • Indexes on partitioned tables
          • Suggestions on using partitioned tables
        • Create and manage indexes
          • About indexes
          • Create an index
          • Drop an index
        • Create and manage views
          • About views
          • Create a view
          • Modify a view
          • Delete a view
        • Create and manage sequences
          • About sequences
          • Create a sequence
          • Modify a sequence
          • Delete a sequence
        • Create and manage triggers
          • About triggers
          • Create a trigger
          • Delete a trigger
      • Query
        • About queries
        • Single-table queries
        • Conditional queries
        • ORDER BY queries
        • GROUP BY queries
        • Use the LIMIT clause in queries
        • Query data from multiple tables
          • About multi-table join queries
          • INNER JOIN queries
          • OUTER JOIN queries
          • Subqueries
        • Use operators and functions in a query
          • Use arithmetic operators in queries
          • Use numerical functions in queries
          • Use string connectors in queries
          • Use string functions in queries
          • Use datetime functions in queries
          • Use type conversion functions in queries
          • Use aggregate functions in queries
          • Use NULL-related functions in queries
          • Use the CASE conditional operator in queries
          • Use the SELECT FOR UPDATE statement to lock query results
        • Execution plan
          • View an execution plan
          • Understand an execution plan
        • Use SQL hints in queries
        • Variables of query timeout
      • DML statements and transactions
        • DML statement
          • About DML statements
          • About the INSERT statement
          • UPDATE statements
          • About the DELETE statement
          • About the REPLACE INTO statement
        • Transactions
          • About transaction control statements
          • Start a transaction
          • Transaction savepoints
          • Commit a transaction
          • Roll back a transaction
          • About transaction timeout
      • Common errors and solutions
        • About error codes
        • Database connection error
        • About timeout
          • Idle session timeout
          • Transaction timeout errors
        • About user
          • Locked user
          • Incorrect user password
        • About table
          • Table already exists
          • Table does not exist
          • Invalid use of NULL value
        • About constraint
          • Unique key conflict
          • Foreign key conflict
        • About SQL commands
          • Data truncation
    • Develop (Oracle Mode)
      • Connect to Oceanbase Database with client
        • Overview
        • Connect to an OceanBase tenant by using an Oracle client
        • Connect to an OceanBase Database tenant by using OBClient
        • Connect to OceanBase Database by using ODC
      • Application development
        • Java application
          • OceanBase Connector/J
          • Java APIs
          • Connect Java applications to OceanBase Database
        • Python application
          • OceanBase Connector/J in Python
          • Python APIs
          • Connect Python applications to OceanBase Database
        • 300.c-application-1
          • OceanBase Connector/C
          • OBCI APIs
          • Connect C applications to OceanBase Database
      • Create and manage database objects
        • About DDL statements
        • View the currently connected database
        • Change the password of a user
        • Data type
          • General data types
          • Unsupported data types
        • Create and manage tables
          • About tables
          • Create a table
          • Define an auto-increment column by using the SEQUENCE keyword
          • About types of column constraints
          • About table structure modification
          • About table clearing
          • About table dropping
          • Flash back a dropped table
          • About table privileges
        • Create and manage partition tables
          • About partitioned tables
          • Create a partitioned table
          • Manage a partitioned table
          • Create a subpartitioned table
          • Manage a subpartitioned table
          • Partition routing
          • Indexes on partitioned tables
          • Suggestions on using partitioned tables
        • Create and manage indexes
          • Drop an index
          • About indexes
          • Create an index
        • Create and manage views
          • About views
          • Create a view
          • Modify a view
          • Drop a view
        • Create and manage sequences
          • About sequences
          • Create a sequence
          • Modify a sequence
          • Delete a sequence
        • Create and manage synonyms
          • About synonyms
          • Create a synonym
          • Delete a synonym
        • Create and manage triggers
          • About triggers
          • Create a trigger
          • Modify a trigger
          • Delete a trigger
          • Enable or disable a trigger
      • Query
        • About queries
        • Single-table queries
        • Conditional queries
        • ORDER BY queries
        • GROUP BY queries
        • Use Row_Limiting_Clause in queries
        • Query data from multiple tables
          • About multi-table join queries
          • INNER JOIN queries
          • OUTER JOIN queries
          • Subqueries
        • Use operators and functions in a query
          • Use arithmetic operators in queries
          • Use numerical functions in queries
          • Use string concatenation operators in queries
          • Use string functions in queries
          • Use datetime functions in queries
          • Use type conversion functions in queries
          • Use aggregate functions in queries
          • Use NULL-related functions in queries
          • Use CASE functions in queries
          • Use the SELECT FOR UPDATE statement to lock query results
        • Execution plan
          • View execution plans of queries
          • Understand an execution plan
        • Use SQL hints in queries
        • About query timeout variables
      • DML statements and transactions
        • DML statement
          • About DML statements
          • About the INSERT statement
          • UPDATE statements
          • About the MERGE statement
          • About the DELETE statement
        • Transactions
          • About transaction control statements
          • Start a transaction
          • Transaction savepoints
          • Commit a transaction
          • Roll back a transaction
          • About transaction timeout
      • Common errors and solutions
        • Overview
        • Database connection error
        • About timeout
          • Idle session timeout
          • Transaction timeout errors
        • About user
          • Locked user
          • Incorrect user password
        • About object
          • Object already exists
          • Object does not exist
        • About constraint
          • Unique key conflict
          • Foreign key conflict
        • About sql
          • Data type inconsistency
  • Deploy
    • Overview
    • Deployment procedure
    • Preparations before deployment
      • Prepare servers
      • Configure servers
      • Prepare installation packages
    • HA solution for OceanBase clusters
    • Deploy through the CLI
      • Configure the deployment environment
        • Install oat-cli
        • Use oat-cli to configure the deployment environment
        • Configure the clock source
        • Upload installation packages
        • Configure host information
        • Check the environment before deployment
      • Deploy OCP
        • Deployment description
        • Generate a configuration file
        • Start deployment
        • Check after deployment
      • Deploy the OceanBase cluster
        • Deploy a single-replica OceanBase cluster
        • Deploy a three-replica OceanBase cluster
      • Deploy OBProxy
        • Deploy OBProxy through the CLI
      • Create an OceanBase tenant
        • View resources available for a business tenant
        • Create a tenant
        • Verify after deployment
      • Deploy OMS
        • Deployment description
        • Modify the configuration file
        • Start deployment
        • Check after deployment
      • Deploy ODC
        • Deployment description
        • Modify the configuration file
        • Start deployment
        • Check after deployment
  • Migrate
    • Overview
    • Migrate data by using SQL scripts
    • Migrate data by using MySQLDump
    • Migrate data by using DataX
    • Migrate data by using OUTFILE statements

Download PDF

Overview System architecture Compatibility with MySQL Overview SQL data types Built-in functions System views Limits Quick start with OceanBase Database Usage notes Basic SQL operations (MySQL mode) Basic SQL operations (Oracle mode) Connect Python applications to OceanBase Database Connect Java applications to OceanBase Database Connect C applications to OceanBase Database Connect Python applications to OceanBase Database Connect Java applications to OceanBase Database Connect C applications to OceanBase Database Experience operational OLAP Experience parallel import and data compression Experience the multitenancy feature Overview Deployment procedure Prepare servers Configure servers Prepare installation packages HA solution for OceanBase clustersOverview Migrate data by using SQL scripts Migrate data by using MySQLDumpMigrate data by using DataX Migrate data by using OUTFILE statements
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.0.0
iconOceanBase Database
SQL - V 4.0.0Enterprise 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

General data types

Last Updated:2023-07-24 09:52:12  Updated
share
What is on this page
Character data types
Numeric data types
Datetime and interval data types
Date and time data types
Interval data types
Related fields and values
RAW data type
Rowid data types
User-defined data types
Any type
Examples
Example 1
Example 2

folded

share

In OceanBase Database in Oracle mode, general data types include character, numeric, datetime, interval, RAW, and LOB. This topic describes these data types.

Character data types

Character data types: CHAR, NCHAR, NVARCHAR2, VARCHAR2, and VARCHAR.

Data type Length type Usage notes Length
CHAR(size [BYTE CHAR]) Fixed This data type features high index efficiency. You can use trim to remove excess blanks in a program. The value range of the size parameter is [1,2000]. The default and minimum values are 1. The storage size is size characters.
NCHAR[(size)] Fixed This data type uses the UNICODE character set. Each character requires two bytes of storage. The value range of the size parameter is [1,2000]. The default and minimum values are 1. The storage size is size characters.
NVARCHAR2(size) Variable This data type uses the UNICODE character set. Each character requires two bytes of storage. The value range of the size parameter is [1,32767]. The storage size is size characters.
VARCHAR2(size [BYTE CHAR]) Variable This data type uses the UNICODE character set. Each character requires two bytes of storage. The value range of the size parameter is [1,32767]. The storage size is the actual length of the bytes or characters entered, and the maximum length is size bytes or characters.
VARCHAR(size [BYTE CHAR]) Variable In OceanBase Database, VARCHAR and VARCHAR2 are the same. The value range of the size parameter is [1,32767]. The storage size is the actual length of the bytes entered, and the maximum length is size bytes.

Numeric data types

Numeric data types: NUMBER, FLOAT, BINARY_FLOAT, and BINARY_DOUBLE

Data type Fixed/Variable length Length (bytes) Usage notes
NUMBER(p,s) Variable [4,40] The variable-length fixed-point numbers with decimal precision or floating-point numbers. When it is the data type of floating-point numbers, the NUMBER data type does not include the p and s parameters.
FLOAT(p) Variable [4,40] The sub-type of the NUMBER data type. Binary precision range: [1,126]. FLOAT does not indicate floating-point numbers.
BINARY_FLOAT Fixed 4 The floating-point numbers with binary precision. It is the data type of the floating-point numbers with 32-place single precision.
BINARY_DOUBLE Fixed 8 The floating-point numbers with binary precision. It is the data type of the floating-point numbers with 64-place dual precision.

Datetime and interval data types

Date and time data types

The datetime data types store date and time information. The following table lists datetime data types supported by OceanBase Database.

Data types Description
DATE The date and time, which is accurate to seconds and contains no time zone.
TIMESTAMP It is an extended type of the DATE data type, which is accurate to nanoseconds and contains no time zone.
TIMESTAMP WITH TIME ZONE It is an extended type of the DATE data type, which is accurate to nanoseconds and contains the time zone.
TIMESTAMP WITH LOCAL TIME ZONE The TIMESTAMP with local time zone information, which stores database time zone.

Interval data types

The interval data types store a period, unlike the datetime data types that store a specific point in time. The interval data types store the difference between two datetime values. The following table lists the interval data types.

Data type Note
INTERVAL YEAR TO MONTH The time interval in years and months.
INTERVAL DAY TO SECOND The time interval in days, hours, minutes, and seconds.

Related fields and values

Datetime and interval data consist of fields, and the values of these fields decide the value of the data types.

Field Value range of datetime Value range of interval
YEAR [-4712,9999], excluding year 0. Any positive or negative integer.
MONTH [01,12]. [0,11]
DAY [01,31]. The value range is determined by the values of MONTH and YEAR and complies with the rule of the NLS calendar. Any positive or negative integer.
HOUR [00,23] [0,23]
MINUTE [00,59] [0,59]
SECOND [00,59.9(n)], where (n) is the decimal accuracy of the time in seconds. 9(n) does not apply to DATE. [0,59.9(n)], where (n) is the decimal accuracy of the interval in seconds.
TIMEZONE_HOUR [-12,14]. This range applies to daylight saving time and does not apply to DATE or TIMESTAMP. N/A
TIMEZONE_MINUTE [00,59]. This range does not apply to DATE or TIMESTAMP. N/A
TIMEZONE_REGION You can query the TZNAME column of the V$TIMEZONE_NAMES data dictionary view to get the value range. This range does not apply to DATE or TIMESTAMP. N/A
TIMEZONE_ABBR You can query the TZABBREV column of the V$TIMEZONE_NAMES data dictionary view to get the value range. This range does not apply to DATE or TIMESTAMP. N/A

RAW data type

The RAW data type is a length-variable data type. The binary data flows can be transmitted between databases with different character sets and between database servers and clients with different character sets, without character set conversion.

Type Value range Description
RAW If you use this parameter to specify the length of a table column in a database, a maximum of 2,000 bytes can be stored in the column. If you use this parameter to specify the length of a PL variable, a maximum of 32,767 bytes can be stored in the variable. The RAW data type stores binary data or strings such as images or audio files.

Rowid data types

Rowid data types: Rowid and URowid

Type Description
Rowid You can query the ROWID pseudocolumn to examine a ROWID. A value in this pseudocolumn is a string representing the address of a row. The data type of these strings is ROWID. You can also create a table that has a column of the ROWID type. A ROWID is converted from a Base64-encoded string.
URowid Some tables have rows with nonphysical or nonpermanent addresses or addresses that are not generated by OceanBase Database. For example, row addresses in an index organization table are stored in the index leaves and can be moved. An index organization table has logical UROWIDs and stores them`` in the ROWID pseudocolumn.

User-defined data types

User-defined data types: object, array, and nested table

Type Description
Object Type An object type is an abstraction of a real-world entity, such as a purchase order, that application programs deal with. An object type is a schema object that consists of three kinds of components:
  • A name, which uniquely identifies the object type within the schema.
  • Attributes, which are built-in types or other custom types. Attributes model the structure and state of the real-world entity.
  • Methods, which are functions or procedures written in PL/SQL and stored in the database. A method can be used by an application to execute the real-world entity.
Arrays An array is an ordered set of data elements. All elements of a specified array are of the same datatype. Each element has an index, which is a number corresponding to the position of the element in the array. The number of elements in the array indicates the array size. OceanBase Database allows arrays to be of variable sizes. That is why they are called VARRAYs. You must specify the maximum size of an array when you declare the array. Declaring an array does not allocate space. It defines a data type that you can use as:
  • An object type attribute.
  • A PL/SQL variable, parameter, or function return type.
Nested tables A nested table is an unordered set of data elements. Both built-in data types and custom data types can be used as elements in a nested table. A nested table has a single column. If the nested table is an object type, you can take it as a multicolumn table, with a column for each attribute of the object type. A table type definition does not allocate space. It defines a type that you can use as:
  • An object type attribute.
  • A PL/SQL variable, parameter, or function return type.

Any type

OceanBase provides SQL-based interfaces to define new types in case the built-in types and types supported by ANSI cannot meet your requirements. You can implement these types in C/C++, Java, or PL/SQL.

Type Description
ANYTYPE This type contains the description of any named SQL types or unnamed transient types.
ANYDATA This type contains instances of the specified type, data, and a description of the type. These values can be SQL built-in types or custom types.

Examples

Example 1

The following examples verify the general data types such as character, numeric, and date types in OceanBase Database.

  1. Create a table named t_data_types.

    CREATE TABLE t_data_types(
      id number NOT NULL PRIMARY KEY,
      c_char char(100),
      c_varchar varchar2(100),
      c_nchar nchar(100),
      c_nvarchar nvarchar2(100),
      c_numeric numeric(10, 2),
      c_int int,
      c_float float(2),
      c_binary_float binary_float,
      c_binary_double binary_double,
      c_raw raw(2000),
      c_blob blob,
      c_clob clob,
      c_date date,
      c_timestamp timestamp,
      c_timestamp2 timestamp WITH time ZONE,
      c_timestamp3 timestamp WITH LOCAL time zone,
      c_interval_year INTERVAL YEAR TO MONTH,
      c_interval_day INTERVAL DAY TO SECOND
    );
    
  2. Insert data into the All types table.

    INSERT INTO
      t_data_types
    VALUES
      (
        1,
        'BB',
        'CC',
        'DD',
        5,
        6,
        7.0,
        8.0,
        9.0,
        10.0,
        utl_raw.cast_to_raw('17'),
        to_blob('18'),
        to_clob('19'),
        date '1970-11-11',
        TO_TIMESTAMP('1970-12-12 12:12:12', 'YYYY-MM-DD HH24:MI:SS'),
        TIMESTAMP '1970-02-13 13:13:13.123',
        TIMESTAMP '1970-02-14 14:14:14.123',
        INTERVAL '12-3' YEAR TO MONTH,
        INTERVAL '16 16:16:16' DAY TO SECOND
      );
    
  3. Query data in the All types table.

    obclient> select * from t_data_types;
    +----+------------------------------------------------------------------------------------------------------+-----------+--------------------------------------------------------------------------------------------------------+------------+-----------+-------+---------+----------------+-----------------+-------+--------------+--------+-----------+------------------------------+-------------------------------------+------------------------------+-----------------+---------------------+
    | ID | C_CHAR                                                                                               | C_VARCHAR | C_NCHAR                                                                                                | C_NVARCHAR | C_NUMERIC | C_INT | C_FLOAT | C_BINARY_FLOAT | C_BINARY_DOUBLE | C_RAW | C_BLOB       | C_CLOB | C_DATE    | C_TIMESTAMP                  | C_TIMESTAMP2                        | C_TIMESTAMP3                 | C_INTERVAL_YEAR | C_INTERVAL_DAY      |
    +----+------------------------------------------------------------------------------------------------------+-----------+--------------------------------------------------------------------------------------------------------+------------+-----------+-------+---------+----------------+-----------------+-------+--------------+--------+-----------+------------------------------+-------------------------------------+------------------------------+-----------------+---------------------+
    |  1 | BB                                                                                                   | CC        | DD                                                                                                     | 5          |         6 |     7 |       8 |       9.0E+000 |        1.0E+001 | 3137  | 18           | 19     | 11-NOV-70 | 12-DEC-70 12.12.12.000000 PM | 13-FEB-70 01.13.13.123000 PM +08:00 | 14-FEB-70 02.14.14.123000 PM | +12-03          | +16 16:16:16.000000 |
    +----+------------------------------------------------------------------------------------------------------+-----------+--------------------------------------------------------------------------------------------------------+------------+-----------+-------+---------+----------------+-----------------+-------+--------------+--------+-----------+------------------------------+-------------------------------------+------------------------------+-----------------+---------------------+
    1 row in set
    

Example 2

The following example verifies a custom object type in ODC and OceanBase Database.

  1. In the SQL window of ODC, create a table named data_type.

    Image 10

  2. Insert data into the data_type table.

    Image 11

  3. Create a custom type named ob_var.

    Image 12

  4. Create a stored procedure and call the custom type ob_var.

    Image 13

  5. Run the custom data type.

    Image 14

    Note

    You can also run the preceding code in the CLI.

    create table data_type (id number(10),name varchar2(50),age int,address varchar2(50),salary float);//
    
    insert into data_type values(1,'baba',20,'hangzhou',3000.00);//
    
    create or replace type ob_var as object(
      var varchar2(10),
      var1 varchar(10)
    );//
    
    create or replace procedure p_datatype is
    begin
      declare
        rec data_type%rowtype;
        v_age rec.age%type;
        var varchar2(50);
        v_name var%type;
        v_salary data_type.salary%type;
    
        type salary is table of number index by varchar2(20);
        arr salary;
        v_arr arr%type;
    
        CURSOR c2 IS SELECT name, age FROM data_type;
        c_row c2%rowtype;
        v_rec c_row%type;
    
        ob ob_var;
        v_obj ob%type;
      begin
        v_name := 'ali ';
        v_age := 30;
        v_salary := 2000;
        dbms_output.put_line('Referenced item: variable, record, and table column name: ' || v_name  || ' * ' || v_age || ' * ' || v_salary);
    
        v_arr('James') := 78000;
        dbms_output.put_line('Referenced item: name of collection variable ' || v_arr.FIRST);
    
        open c2;
        fetch c2 into v_rec;
        dbms_output.put_line('Referenced item: name of cursor variable: ' || v_rec.name || ' * ' || v_rec.age);
        close c2;
    
        v_obj:=ob_var('test','object');
        dbms_output.put_line('Referenced item: name of the object instance: ' || v_obj.var || ' * ' || v_obj.var1);
      end;
    end;
    //
    
    set serveroutput on;
    
    begin
      p_datatype;
    end;
    //
    

Previous topic

Change the password of a user
Last

Next topic

Unsupported data types
Next
What is on this page
Character data types
Numeric data types
Datetime and interval data types
Date and time data types
Interval data types
Related fields and values
RAW data type
Rowid data types
User-defined data types
Any type
Examples
Example 1
Example 2