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

  • Document overview
  • Overview
    • Overview
    • System architecture
    • Compatibility with MySQL
    • Limits
  • Get Started
    • Quick experience
    • Hands on for OceanBase SQL
      • Before you start
      • Basic SQL operations
    • Create a sample application
      • Connect to OceanBase Database by using a Python driver
      • Connect to OceanBase Database by using Go MySQL Driver
      • Connect a Java application to OceanBase Database
      • Connect a C application to OceanBase Database
    • Experience OceanBase advanced features
      • Experience scalable OLTP
        • Run the TPC-C benchmark test on 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
    • Connect to Oceanbase Database with client
      • Overview
      • Connect to OceanBase Database by using a MySQL client
      • Connect to OceanBase Database by using OBClient
      • Connect to OceanBase Database by using ODC
      • Connect Java applications to OceanBase Database
      • Connect to OceanBase Database by using Go MySQL Driver
      • Connect to OceanBase Database by using Unix ODBC
      • C application
        • OceanBase Connector/C
        • C API functions
        • Connect C applications to OceanBase Database
      • Connect Python applications to OceanBase Database
      • SpringBoot connection example
      • SpringBatch connection example
      • SpringJDBC connection example
      • SpringJPA connection example
      • Hibernate connection example
      • MyBatis 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
    • 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
    • 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
  • Deploy
    • Overview
    • On-premises deployment
      • Software and hardware requirements
      • Configuration before deployment
      • Deploy OceanBase Database online
      • Deploy OceanBase Database offline
    • Deploy OceanBase Database in a Kubernetes cluster
    • High availability deployment
      • Use Alibaba Otter to implement remote active-active disaster recovery
  • Migrate
    • Data Migration Overview
    • Migrate data from MySQL Database to OceanBase
      • Use Canal to synchronize MySQL data to OceanBase Database in real time
      • Use DataX to migrate MySQL data to OceanBase Database
      • Use DBCAT to migrate MySQL table schemas to OceanBase Database
      • Migrate MySQL table schemas to OceanBase Database by using mysqldump
      • Migrate MySQL table data to OceanBase Database by using mysqldump
    • Use OBDUMPER to export data from or OBLOADER to import data to OceanBase Database
    • Migrate data from CSV-file to OceanBase
      • Use DataX to load CSV data files to OceanBase Database
      • Use the LOAD DATA statement to load CSV data files to OceanBase Database
    • Migrate data from SQL files to OceanBase Database
    • Migrate data and resource units between tables
    • Migrate data from OceanBase Database to MySQL
      • Use Canal to synchronize OceanBase Database data to MySQL in real time

Download PDF

Document overview Overview System architecture Compatibility with MySQL Limits Quick experience Before you start Basic SQL operations Connect to OceanBase Database by using a Python driver Connect to OceanBase Database by using Go MySQL Driver Connect a Java application to OceanBase Database Connect a C application to OceanBase Database Experience operational OLAP Experience parallel import and data compression Experience the multitenancy feature Overview Connect to OceanBase Database by using a MySQL client Connect to OceanBase Database by using OBClient Connect to OceanBase Database by using ODC Connect Java applications to OceanBase Database Connect to OceanBase Database by using Go MySQL Driver Connect to OceanBase Database by using Unix ODBC Connect Python applications to OceanBase Database SpringBoot connection example SpringBatch connection example SpringJDBC connection example SpringJPA connection example Hibernate connection example MyBatis connection example About DDL statements View the currently connected database Change the password of a user About queries Single-table queries Conditional queries ORDER BY queries GROUP BY queries Use the LIMIT clause in queries Use SQL hints in queries Variables of query timeout About error codes Database connection error Overview Software and hardware requirements Configuration before deployment Deploy OceanBase Database online Deploy OceanBase Database offline Deploy OceanBase Database in a Kubernetes cluster Use Alibaba Otter to implement remote active-active disaster recovery Data Migration Overview Use Canal to synchronize MySQL data to OceanBase Database in real time Use DataX to migrate MySQL data to OceanBase Database Use DBCAT to migrate MySQL table schemas to OceanBase Database Migrate MySQL table schemas to OceanBase Database by using mysqldump Migrate MySQL table data to OceanBase Database by using mysqldump Use OBDUMPER to export data from or OBLOADER to import data to OceanBase Database Use DataX to load CSV data files to OceanBase Database Use the LOAD DATA statement to load CSV data files to OceanBase Database Migrate data from SQL files to OceanBase Database Migrate data and resource units between tables Use Canal to synchronize OceanBase Database data to MySQL in real time
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.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

General data types

Last Updated:2023-07-21 09:11:01  Updated
share
What is on this page
Numeric data types
Date and time data types
Character data types
BLOB data types
Text data types
ENUM data type
SET data type
JSON data type
Examples
Example 1
Example 2
Example 3
Example 4
Example 5
Example 6
Example 7

folded

share

In OceanBase Database in MySQL mode, the general data types include numeric, date and time, character, LOB, text, enumeration, set, and JSON. This topic describes these data types.

Numeric data types

Numeric data types include:

  • Integer data types: BOOL, BOOLEAN, or TINYINT, SMALLINT, MEDIUMINT, INT or INTEGER, and BIGINT

  • Fixed-point types: DECIMAL and NUMERIC

  • Floating-point types: FLOAT and DOUBLE

  • Bit-value type: BIT

Category Type Value range Description
Numeric data type - integer BIGINT Signed: [-263,263 - 1]
Unsigned: [0,264 - 1]
Represents a large integer.
INT
INTEGER
Signed: [-231,231 - 1]
Unsigned: [0,232 - 1]
Represents a normal-sized integer.
SMALLINT Signed: [-215,215 - 1]
Unsigned: [0,216 - 1]
Represents a small integer.
BOOL
BOOLEAN
TINYINT
Signed: [-27,27 - 1]
Unsigned: [0,28 - 1]
  • The TINYINT data type is used to represent a very small integer.
  • The BOOL/BOOLEAN data type is a synonym for the TINYINT data type. A zero value indicates false, whereas a non-zero value indicates true.
Numeric data type - fixed-point DECIMAL The scale and precision depend on D and M, and whether the value is unsigned. M specifies the precision, which is the total number of digits that can be stored. D specifies the scale, which is the number of decimal places. The decimal point (.) and minus sign (-) are not counted in M. If D is 0, the value does not have the decimal point or fractional part. The result of subtracting D from M is the maximum number of valid digits in the integer part. When neither M nor D is specified, the precision is 65 digits for the results of all basic operations (addition, subtraction, multiplication, and division) involving a DECIMAL column. DECIMAL is equivalent to NUMERIC.
Numeric data type - floating-point FLOAT Signed: [-2128,2128]
Unsigned: [-21024,21024]
Precision: 7 digits.
Represents a small (single-precision) floating-point number.
DOUBLE Signed: [-21024,21024]
Unsigned: [0,21024]
Precision: 15 digits.
Represents a normal-sized (double-precision) floating-point number.
Numeric data type - integer/fixed-point/floating point NUMBER
NUMBER(P)
NUMBER(P, S)
P stands for precision, and S stands for scale, the number of digits after the decimal point. The maximum precision is 38 and the scale ranges from -84 to 127.
  • A value with both precision and scale is a fixed-point value.
  • A value with a scale of 0 is an integer value.
  • A value without precision and scale is a floating-point value with a maximum precision of 38.
Includes integers, fixed-point numbers, and floating-point numbers.
Bit-value data type BIT A bit value consists of zeros and ones. The length is 1 bit. Stores bit values.

Date and time data types

Date and time data types: DATETIME, TIMESTAMP, DATE, TIME, and YEAR

Category Type Value range Description
Date and time DATE The DATE type is used for values that contain only a date. The DATE values are retrieved and displayed in YYYY-MM-DD format. Represents a value with only the date part but no time part.
TIME A TIME value contains only the time part and is displayed in the HH:MM:SS[.fraction] format. Represents a point in time in a day, the elapsed time, or the time interval between two events, which may be far greater than 24 hours.
DATETIME A DATETIME value contains both the date and time (not time zone specific) parts, and is displayed in the YYYY-MM-DD HH:MM:SS[.fraction] format. Represents a value that contains both the date and time parts.
TIMESTAMP A TIMESTAMP value contains both the date and time (time zone specific) parts. Represents a value that contains both the date and time parts.
YEAR YYYY,[1901, 2155] Represents a 4-digit year.

Character data types

Character data types: CHAR, VARCHAR, BINARY, and VARBINARY

Category Type Value range Description
Character data type - variable-length VARCHAR(N) Maximum length: 256 KB. Character set: UTF8MB4. The declared length is the maximum number of characters that can be stored.
VARBINARY Maximum length: 256 KB. Character set: BINARY. It is similar to the VARCHAR data type but stores binary byte strings.
Character data type - fixed-length CHAR(N) Maximum length: 256. Character set: UTF8MB4. The declared length is the maximum number of characters that can be stored.
BINARY Maximum length: 256. Character set: BINARY. It is similar to the CHAR data type but stores binary byte strings.

BLOB data types

BLOB data types: TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB

Category Type Value range Description
Type TINYBLOB Binary text that contains a maximum of 255 characters or is up to 255 bytes in size. Represents a BLOB type with a maximum length of 255 bytes.
BLOB Long binary text that is up to 65 KB in size. Represents a BLOB type with a maximum length of 65,535 bytes.
MEDIUMBLOB Longer binary text that is up to 16 MB in size. Represents a BLOB type with a maximum length of 16,777,215 bytes.
LONGBLOB Ultra-long binary text that is up to 4 GB in size. Represents a BLOB type with a maximum length of 4,294,967,295 bytes.

Text data types

Text data types: TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT

Category Type Value range Description
Type TINYTEXT Up to 255 bytes, [28 - 1]. Represents a TEXT type with a maximum length of 256 characters. If the value contains a multi-byte character, the maximum valid length is reduced.
TEXT Up to 65 KB in size, [216 - 1] Represents a TEXT type with a maximum length of 65,536 characters. If the value contains a multi-byte character, the maximum valid length is reduced.
MEDIUMTEXT Up to 16 MB in size, [224 - 1] Represents a TEXT type with a maximum length of 16,777,216 characters. If the value contains a multi-byte character, the maximum valid length is reduced.
LONGTEXT Up to 48 MB in size. Represents a TEXT type with a maximum length of 50,331,648 characters or 48 MB in size. If the value contains a multi-byte character, the maximum valid length is reduced. The maximum valid length of a LONGTEXT column also depends on the maximum packet size and available memory configured in the client/server protocol.

ENUM data type

Enumeration data type: One value is selected within a given range, for example, male or female for gender.

Classification Type Value range Description
Type ENUM Maximum number of elements: 65,535. Maximum length of each element: 255 characters. Character set: UTF8MB4. Represents a string object with only one value. The value must be sourced from the list 'value1', 'value2', ... Enumerated values must be strings with quotation marks.

SET data type

Set data type: One or more values can be selected within a given range.

Classification Type Value range Description
Type SET Maximum number of elements: 65,535. Maximum length of each element: 255 characters. Character set: UTF8MB4. Represents a string object with zero or more values, and each value is sourced from the list 'Value1', 'Value2', ...

JSON data type

Classification Type Value range Description
Type JSON JSON data can be in the form of objects or arrays. The JSON data type uses a lightweight text data format to store and represent data.

Examples

Example 1

  1. Create a table named All types.

    CREATE TABLE `All types` (
      `col1` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Column 1',
      `col2` integer DEFAULT NULL COMMENT 'Column 2',
      `col3` decimal(10,2) DEFAULT NULL COMMENT 'Column 3',
      ` col4` number DEFAULT NULL COMMENT 'Column 4',
      `col5` tinyint(4) DEFAULT NULL COMMENT 'Column 5',
      `col6` smallint(6) DEFAULT NULL COMMENT 'Column 6',
      `col7` mediumint(9) DEFAULT NULL COMMENT 'Column 7',
      `col8` bigint(20) DEFAULT NULL COMMENT 'Column 8',
      `col9` float(10,2) DEFAULT NULL COMMENT 'Column 9',
      `col10` double(10,2) DEFAULT NULL COMMENT 'Column 10',
      `col11` varchar(10) DEFAULT NULL COMMENT 'Column 11',
      `col12` char(10) NOT NULL DEFAULT 'Chinese field' COMMENT 'Column 12',
      `col13` text DEFAULT NULL COMMENT 'Column 13',
      `col14` tinytext DEFAULT NULL COMMENT 'Column 14',
      `col15` mediumtext DEFAULT NULL COMMENT 'Column 15',
      `col16` longtext DEFAULT NULL COMMENT 'Column 16',
      `col17` blob DEFAULT NULL COMMENT 'Column 17',
      `col18` tinyblob DEFAULT NULL COMMENT 'Column 18',
      `col19` longblob DEFAULT NULL COMMENT 'Column 19',
      `col20` mediumblob DEFAULT NULL COMMENT 'Column 20',
      `col21` binary(16) DEFAULT NULL COMMENT 'Column 21',
      `col22` varbinary(16) DEFAULT NULL COMMENT 'Column 22',
      `col23` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Column 23',
      `col24` time DEFAULT NULL COMMENT 'Column 24',
      `col25` date DEFAULT NULL COMMENT 'Column 25',
      `col26` datetime DEFAULT NULL COMMENT 'Column 26',
      `col27` year(4) DEFAULT NULL COMMENT 'Column 27',
      PRIMARY KEY (`col1`)
    ) AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMPRESSION = 'zstd_1.0' REPLICA_NUM = 1 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0 COMMENT = 'All types';
    
  2. Insert data into the All types table.

    obclient> INSERT INTO `full-type table` VALUES(101,2,3,4,5,6,7,8,9.1,10.1,'Eleven','Twelve','Thirteen','Fourteen','Fifteen','Sixteen','Seventeen','Eighteen','Nineteen','Twenty','Twenty-one','Twenty-two','19700101','00:00:00','19700101','19700101','1970');
    Query OK, 1 row affected
    
  3. Query data in the All types table.

    obclient> select * from `All types`;
    +------+------+------+-------+------+------+------+------+------+-------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------------------+-----------+---------------------+----------+------------+---------------------+-------+
    | col1 | col2 | col3 |  col4 | col5 | col6 | col7 | col8 | col9 | col10 | col11  | col12  | col13  | col14  | col15  | col16  | col17  | col18  | col19  | col20  | col21            | col22     | col23               | col24    | col25      | col26               | col27 |
    +------+------+------+-------+------+------+------+------+------+-------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------------------+-----------+---------------------+----------+------------+---------------------+-------+
    |  101 |    2 | 3.00 |     4 |    5 |    6 |    7 |    8 | 9.10 | 10.10 | Eleven   | Twelve   | Thirteen   | Fourteen   | Fifteen   | Sixteen   | Seventeen   | Eighteen   | Nineteen   | Twenty   | Twenty-one           | Twenty-two    | 1970-01-01 00:00:00 | 00:00:00 | 1970-01-01 | 1970-01-01 00:00:00 |  1970 |
    +------+------+------+-------+------+------+------+------+------+-------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+------------------+-----------+---------------------+----------+------------+---------------------+-------+
    1 row in set
    

Example 2

  1. Create a table named t_bool.

    obclient> CREATE TABLE t_bool(c1 bool);
    Query OK, 0 rows affected
    
  2. Insert data into the t_bool table.

    obclient> INSERT INTO t_bool VALUES(1);
    Query OK, 1 row affected
    
  3. Query data in the t_bool table.

    obclient> SELECT * FROM t_bool;
    +------+
    | c1   |
    +------+
    |    1 |
    +------+
    1 row in set
    

Example 3

  1. Create a table named t_boolean.

    obclient> CREATE TABLE t_boolean(c1 boolean);
    Query OK, 0 rows affected
    
  2. Insert data into the t_boolean table.

    obclient> INSERT INTO t_boolean VALUES(1);
    Query OK, 1 row affected
    
  3. Query data in the t_boolean table.

    obclient> SELECT * FROM t_boolean;
    +------+
    | c1   |
    +------+
    |    1 |
    +------+
    1 row in set
    

Example 4

  1. Create a table named t_bit.

    obclient> CREATE TABLE t_bit(c1 bit(8));
    Query OK, 0 rows affected
    
  2. Insert data into the t_bit table.

    obclient> INSERT INTO t_bit VALUES(101);
    Query OK, 1 row affected
    
  3. Query data in the t_bit table.

    obclient> SELECT c1,bin(c1),hex(c1) FROM t_bit;
    +------+---------+---------+
    | c1   | bin(c1) | hex(c1) |
    +------+---------+---------+
    | e    | 1100101 | 65      |
    +------+---------+---------+
    1 row in set
    

Example 5

  1. Create a table named t_enum.

    obclient> CREATE TABLE t_enum(c1 enum('RED','GREEN','BLUE'));
    Query OK, 0 rows affected
    
  2. Insert data into the t_enum table.

    obclient> INSERT INTO t_enum VALUES('RED');
    Query OK, 1 row affected
    
  3. Query data in the t_enum table.

    obclient>  SELECT * FROM t_enum;
    +------+
    | c1   |
    +------+
    | RED  |
    +------+
    1 row in set
    

Example 6

  1. Create a table named t_enum.

    obclient> CREATE TABLE t_enum(c1 enum('RED','GREEN','BLUE'));
    Query OK, 0 rows affected
    
  2. Insert data into the t_enum table.

    obclient> INSERT INTO t_enum VALUES('RED');
    Query OK, 1 row affected
    
  3. Query data in the t_enum table.

    obclient>  SELECT * FROM t_enum;
    +------+
    | c1   |
    +------+
    | RED  |
    +------+
    1 row in set
    

Example 7

  1. Create a table named t_json.

    obclient> CREATE TABLE t_json(c1 json);
    Query OK, 0 rows affected
    
  2. Insert data into the t_json table.

    obclient>  INSERT INTO t_json VALUES( '{"name":"ny", "gender":"Male","age":22}' );
    Query OK, 1 row affected
    
  3. Query data in the t_json table.

    obclient> SELECT * FROM t_json;
    +--------------------------------------------+
    | c1                                         |
    +--------------------------------------------+
    | {"age": 22, "name": "ny", "gender": "Male"}  |
    +--------------------------------------------+
    1 row in set
    

Previous topic

Change the password of a user
Last

Next topic

Unsupported data types
Next
What is on this page
Numeric data types
Date and time data types
Character data types
BLOB data types
Text data types
ENUM data type
SET data type
JSON data type
Examples
Example 1
Example 2
Example 3
Example 4
Example 5
Example 6
Example 7