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

    Create a database

    Last Updated:2023-10-27 09:57:43  Updated
    share
    What is on this page
    Create a database by using an SQL statement
    Create a database in OCP

    folded

    share

    This topic describes how to create a database in MySQL mode.

    Create a database by using an SQL statement

    You can use the CREATE DATABASE statement to create a database.

    Examples:

    • Create a database named test2 and specify the character set as UTF8.

      obclient> CREATE DATABASE test2 DEFAULT CHARACTER SET UTF8;
      Query OK, 1 row affected
      
    • Create a database named test3 that supports read and write operations.

      obclient> CREATE DATABASE test3 READ WRITE;
      Query OK, 1 row affected
      
    • Create a read-only database named test4.

      obclient> CREATE DATABASE test4 READ ONLY;
      Query OK, 1 row affected
      

      For more information about the syntax of the CREATE DATABASE statement, see CREATE DATABASE.

    Create a database in OCP

    You can also create a database for a MySQL tenant in OceanBase Cloud Platform (OCP).

    Before you create a database, make sure that the password box of the current OCP user contains the root password of the tenant. Otherwise, the creation fails. To create a database in OCP, perform the following steps.

    1. Log on to the OCP console.

    2. In the left-side navigation pane, click Tenants to go to the Tenants page.

    3. In the tenant list, find the required tenant and click the tenant name. The Overview page appears.

    4. In the left-side navigation pane, click Database Management. The Database Management page appears.

    5. In the upper-right corner of the page, click Create Database.

    6. In the panel that appears, enter the database information.

      Field Description
      Database Name The database name. The name must be 2 to 128 characters in length and can contain lowercase letters, digits, and underscores (_). The name must start with a letter.
      Character Set The character set of the database. Valid values:
      • utf8mb4: encodes data into variable-length characters. The maximum length of an encoded character is 4 bytes.
      • binary: encodes data into characters with a fixed length of 1 byte.
      • gbk: encodes data into 2-byte characters.
      • gb18030: encodes data into 1-byte, 2-byte, or 4-byte characters.
      Collation The collation of the specified character set.
      Valid collations for the utf8mb4 character set:
      • utf8mb4_bin: compares the binary values of characters. Characters are case-sensitive in this collation.
      • utf8mb4_general_ci: does not follow the Unicode rules and may generate undesirable sorting and comparison results in specific scenarios that involve particular languages or character sets. Characters are case-insensitive in this collation.
      • utf8mb4_unicode_ci: follows the standard Unicode rules to perform sorting and comparison. This collation can provide accurate results for various languages. Characters are case-insensitive in this collation.

      Valid collation for the binary character set: binary.
      Valid collations for the gbk character set:
      • gbk_bin: compares characters based on the encoded values. Characters are case-sensitive in this collation.
      • gbk_chinese_ci: Characters are case-insensitive in this collation.

      Valid collations for the gb18030 character set:
      • gb18030_bin: Characters are case-sensitive in this collation.
      • gb18030_chinese_ci: Characters are case-insensitive in this collation.
      Read-only Specifies whether the database is read-only.
      • Yes: Only the root user under the current tenant has read/write permissions on the database.
      • No: All users under the current tenant have read/write permissions on the database.
      Zone Priority The priorities of the zones. This is an advanced setting.

      Create Database panel

    7. Click Submit.

    Previous topic

    Manage DBLinks
    Last

    Next topic

    View databases
    Next
    What is on this page
    Create a database by using an SQL statement
    Create a database in OCP