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 - V3.2.4Enterprise Edition

    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. V3.2.4
    iconOceanBase Database
    SQL - V 3.2.4Enterprise Edition
    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

    Integer data types

    Last Updated:2023-10-24 09:23:03  Updated
    Share
    What is on this page
    TINYINT
    BOOL or BOOLEAN
    SMALLINT
    MEDIUMINT
    INT or INTEGER
    BIGINT

    folded

    Share

    Integer data types are used to store precise numeric values with fixed lengths. The value range of an integer data type depends on the length of the data type and whether the data type is unsigned. The precision of an integer data type indicates the minimum display width.

    The following table describes the length and value range of each integer data type supported by OceanBase Database.

    Data type
    Length (bytes)
    Value range (signed)
    Value range (unsigned)
    BOOL, BOOLEAN, or TINYINT 1 [-2^7^, 2^7^ - 1] [0, 2^8^ - 1]
    SMALLINT 2 [-2^15^, 2^15^ - 1] [0, 2^16^ - 1]
    MEDIUMINT 3 [-2^23^, 2^23^ - 1] [0, 2^24^ - 1]
    INT or INTEGER 4 [-2^31^, 2^31^ - 1] [0, 2^32^ - 1]
    BIGINT 8 [-2^63^, 2^63^ - 1] [0, 2^64^ - 1]

    TINYINT

    The TINYINT data type is used to represent a very small integer. Syntax:

    TINYINT[(M)] [UNSIGNED] [ZEROFILL]
    

    M indicates the maximum display width. The maximum value of M is 255. The display width is independent of the range of values that can be stored. If you specify the ZEROFILL attribute for a column, OceanBase Database automatically adds the UNSIGNED attribute to the column.

    BOOL or BOOLEAN

    The BOOL or BOOLEAN data type is a synonym for the TINYINT data type. A zero value indicates false, whereas a non-zero value indicates true.

    Examples:

    obclient> SELECT IF(0, 'true', 'false');
    +------------------------+
     IF(0, 'true', 'false') 
    +------------------------+
     false                  
    +------------------------+
    1 row in set (0.01 sec)
    
    obclient> SELECT IF(1, 'true', 'false');
    +------------------------+
     IF(1, 'true', 'false') 
    +------------------------+
     true                   
    +------------------------+
    1 row in set (0.00 sec)
    
    obclient> SELECT IF(2, 'true', 'false');
    +------------------------+
     IF(2, 'true', 'false') 
    +------------------------+
     true                   
    +------------------------+
    1 row in set (0.00 sec)
    
    obclient> SELECT IF(2 = FALSE, 'true', 'false');
    +--------------------------------+
     IF(2 = FALSE, 'true', 'false') 
    +--------------------------------+
     false                          
    +--------------------------------+
    1 row in set (0.00 sec)
    

    SMALLINT

    The SMALLINT data type is used to represent a small integer. Syntax:

    SMALLINT[(M)] [UNSIGNED] [ZEROFILL]
    

    M indicates the maximum display width. The maximum value of M is 255. The display width is independent of the range of values that can be stored. If you specify the ZEROFILL attribute for a column, OceanBase Database automatically adds the UNSIGNED attribute to the column.

    MEDIUMINT

    The MEDIUMINT data type is used to represent a medium-sized integer.

    Syntax:

    MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL]
    

    M indicates the maximum display width. The maximum value of M is 255. The display width is independent of the range of values that can be stored. If you specify the ZEROFILL attribute for a column, OceanBase Database automatically adds the UNSIGNED attribute to the column.

    INT or INTEGER

    The INT or INTEGER data type is used to represent a normal-sized integer. Syntax:

    INT[(M)] [UNSIGNED] [ZEROFILL]
    INTEGER[(M)] [UNSIGNED] [ZEROFILL]
    

    M indicates the maximum display width. The maximum value of M is 255. The display width is independent of the range of values that can be stored. If you specify the ZEROFILL attribute for a column, OceanBase Database automatically adds the UNSIGNED attribute to the column.

    BIGINT

    The BIGINT data type is used to represent a large integer. Syntax:

    BIGINT[(M)] [UNSIGNED] [ZEROFILL]
    

    M indicates the maximum display width. The maximum value of M is 255. The display width is independent of the range of values that can be stored. If you specify the ZEROFILL attribute for a column, OceanBase Database automatically adds the UNSIGNED attribute to the column.

    Usage notes for BIGINT:

    • You must use signed BIGINT or DOUBLE values in all operations. Therefore, you cannot use unsigned integers that are larger than 9223372036854775807 in value or greater than 63 bits in length except in BIT functions. Otherwise, a rounding error may occur when you convert a BIGINT value into a DOUBLE value. As a result, the last digit in the conversion result may be incorrect.

    • You can store an exact integer in a BIGINT column as a string. In this case, OceanBase Database can convert a string into a number without intermediate double-precision representation.

    • If both operands are integers, the BIGINT arithmetic is used for subtraction, addition, and multiplication. In this case, if you multiply two big integers (or integers returned by a function), an exception may occur if the multiplication result is greater than 9223372036854775807.

    Previous topic

    Overview
    Last

    Next topic

    Fixed-point data types
    Next
    What is on this page
    TINYINT
    BOOL or BOOLEAN
    SMALLINT
    MEDIUMINT
    INT or INTEGER
    BIGINT