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 Developer Center

V4.1.0Community Edition

  • Document Overview
  • What's New
    • What's new
  • Overview
    • What is ODC?
    • Benefits
    • Architecture
    • Features
    • Limits
  • Quick Start
    • Overview
    • Install ODC
    • Log on to ODC with an account
    • Create a private connection
  • Tutorials
    • Tips on the SQL Console
    • Create a connection
    • Export data
    • Import data
    • Debug a stored procedure
    • View the performance of an SQL statement
  • User Guide (Web ODC)
    • Log on to ODC
      • Log on to ODC with an account
      • Change the password
    • ODC homepage
    • Connect to a database
      • Create a private connection
      • Manage private connections
    • Public resource management
      • Overview
      • Quick start
      • Resource permissions
        • Manage public connections
        • Manage resource groups
        • Manage roles
        • Manage users
        • Automatic authorization rules
      • Task process management
      • Manage operation records
      • Data desensitization management
      • System settings
    • Use the workspace
      • Overview
      • SQL window
      • Anonymous block window
      • Command-line window
      • Stored scripts
      • Snippet
    • Use tools
      • Data export and import
        • Overview
        • Export and import formats
        • Batch export and import
        • Single table export and import
      • Data mocking
      • Partitioning plan
      • Database changes
      • Shadow table synchronization
      • SQL plan
    • Recycle bin
    • View operation records
    • Task management
      • Overview
      • Import tasks
      • Export tasks
      • Data mocking tasks
      • Database change tasks
      • Partitioning plan task
      • Permission application tasks
      • Shadow table synchronization tasks
      • SQL plan task
    • Session management
    • Database objects
      • Table objects
        • Create a table
        • Create a table
        • Table list
        • Manage table attributes
        • Manage table data
      • View objects
        • Overview
        • Create a view
        • Manage views
      • Function objects
        • Overview
        • Create a function
        • Manage functions
      • Stored procedure objects
        • Overview
        • Create a stored procedure
        • Manage stored procedures
      • Sequence objects
        • Overview
        • Create a sequence
        • Manage sequences
      • Package objects
        • Overview
        • Create a program package
        • Manage program packages
      • Trigger objects
        • Overview
        • Create a trigger
        • Manage triggers
      • Type objects
        • Overview
        • Create a type
        • Manage types
      • Synonym objects
        • Overview
        • Create a synonym
        • Manage synonyms
    • Help center
  • User Guide (Client ODC)
    • Install ODC
    • ODC homepage
    • Connect to a database
      • Create a private connection
      • Manage connections
    • Use the workspace
      • Overview
      • SQL window
      • Anonymous block window
      • Command-line window
      • Stored scripts
      • Snippet
    • Use tools
      • Data export and import
        • Overview
        • Export and import formats
        • Batch export and import
        • Single table export and import
      • Data mocking
      • Asynchronous execution
      • Shadow table synchronization
    • Recycle bin
    • View operation records
    • Task management
      • Overview
      • Import tasks
      • Export tasks
      • Data mocking tasks
      • Database Change
      • Shadow table synchronization tasks
    • Session management
    • Database objects
      • Table objects
        • Overview
        • Create a table
        • Table list
        • Manage table attributes
        • Manage table data
      • View objects
        • Overview
        • Create a view
        • Manage views
      • Function objects
        • Overview
        • Create a function
        • Manage functions
      • Stored procedure objects
        • Overview
        • Create a stored procedure
        • Manage stored procedures
      • Sequence objects
        • Overview
        • Create a sequence
        • Manage sequences
      • Package objects
        • Overview
        • Create a program package
        • Manage program packages
      • Trigger objects
        • Overview
        • Create a trigger
        • Manage triggers
      • Type objects
        • Overview
        • Create a type
        • Manage types
      • Synonym objects
        • Overview
        • Create a synonym
        • Manage synonyms
    • Help center
  • Deployment Guide
    • Deployment overview
    • Preparations before deployment
    • Deploy a single ODC node
      • Deployment process
      • Load and run an ODC image
    • Deploy ODC in high availability mode
      • Deployment process
      • Load and run an ODC image
      • Deploy SSL certificate
      • Deploy the NGINX proxy
      • Configure certificate trust
    • Deployment verification
  • Upgrade Guide
    • Overview
    • Preparations before upgrade
    • Upgrade single-node ODC
      • Upgrade process
      • Stop ODC of the earlier version
      • Load and run an ODC image
    • Upgrade high-availability
      • Upgrade process
      • Stop ODC of the earlier version
      • Load and run an ODC image
      • Upgrade NGINX image
    • Upgrade verification
    • Rollback after upgrade failed
  • FAQ

Download PDF

Document Overview What's newWhat is ODC? Benefits Architecture Features Limits Overview Install ODC Log on to ODC with an account Create a private connection Tips on the SQL Console Create a connection Export data Import data Debug a stored procedure View the performance of an SQL statement Log on to ODC with an account Change the password ODC homepageCreate a private connection Manage private connections Overview Quick start Task process managementManage operation records Data desensitization managementSystem settings Overview SQL windowAnonymous block window Command-line window Stored scripts Snippet Data mocking Partitioning planDatabase changes Shadow table synchronization SQL planRecycle bin View operation records Overview Import tasks Export tasks Data mocking tasks Database change tasks Partitioning plan task Permission application tasks Shadow table synchronization tasks SQL plan taskSession management Help center Install ODC ODC homepage Create a private connection Manage connections Overview SQL windowAnonymous block window Command-line window Stored scripts Snippet Data mocking Asynchronous execution Shadow table synchronizationRecycle bin View operation records Overview Import tasks Export tasks Data mocking tasks Database Change Shadow table synchronization tasksSession management Help center Deployment overview Preparations before deployment Deployment process Load and run an ODC image Deployment process Load and run an ODC image Deploy SSL certificate Deploy the NGINX proxy Configure certificate trust Deployment verificationOverview Preparations before upgrade Upgrade process Stop ODC of the earlier version Load and run an ODC image Upgrade process Stop ODC of the earlier version Load and run an ODC image Upgrade NGINX image Upgrade verification Rollback after upgrade failed FAQ
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 Developer Center
  3. V4.1.0
iconOceanBase Developer Center
V 4.1.0Community Edition
  • V 4.4.2
  • V 4.4.1
  • V 4.4.0
  • V 4.3.4
  • V 4.3.3
  • V 4.3.2
  • V 4.3.1
  • V 4.3.0
  • V 4.2.4
  • V 4.2.3
  • V 4.2.2
  • V 4.2.1
  • V 4.2.0
  • V 4.1.3 and earlier
Community Edition
  • V 4.1.0
  • V 4.0.0
  • V 3.3.2
  • V 3.2.2
Enterprise Edition
  • V 4.1.3
  • V 3.4.0

Create a table

Last Updated:2026-04-13 06:45:38  Updated
share
What is on this page
Overview
Procedure
Step 1: Specify the basic information.
Step 2: Set columns.
Step 3: Set partitioning rules.
Step 4: Set the index.
Step 5: Set constraints.
Step 6: Verify the SQL statement.
Step 7: Complete the table creation.
Related topics

folded

share

Overview

A table is a data structure in a database and stores data in rows and columns.

Create a table

As shown in the preceding figure, you can create a table in the following seven steps:

  1. Specify the basic information.

  2. Set columns.

  3. Set partitioning rules.

  4. Set the index.

  5. Set constraints.

  6. Verify the SQL statement.

  7. Complete the table creation.

Procedure

In the following example, a table named employee is created in the OceanBase Developer Center (ODC) console. The table contains the emp_no, birthdate, name, and gender columns. Procedure:

Step 1: Specify the basic information.

Log on to the ODC console and click the name of the desired connection to go to the corresponding connection management page. You can click Table in the left-side navigation pane to get a list of tables. To create a table, click + in the upper-right corner of the table list or click Create in the top navigation bar.

In the Basic Info section, specify Table Name and Description.

Note
In MySQL mode, you also need to specify Default Character Set and Default Sorting Rule.

Step 1

Step 2: Set columns.

The following figure and table show the information that you need to specify when you add a column.

Step 2

Field Description
Field Name The name of the column.
Data Type The data type of the column.
For more information about data types, see OceanBase Database Developer Guide.
Non-empty Specifies whether the value of the column must be specified.
Auto-increment Specifies whether to set the column to an auto-increment column. This parameter is valid in MySQL mode.
Default Value The default value of the column.
Comment The additional information about the column.

The column setting section also provides three buttons.

Button Description
Create Click this button to add a field.
Edit Click this button to edit the selected field. You can also directly double-click a cell to edit it.
Delete Click this button to delete the selected field.

Step 3: Set partitioning rules.

Step 3

You can partition a table that contains a large amount of data. After a table is partitioned, data in the table is stored in multiple tablespaces. The database does not scan the entire table for a query.

  • In MySQL mode, OceanBase Database supports the following six partitioning methods: Key, Hash, Range, Range Columns, List, and List Columns.

  • In Oracle mode, OceanBase Database supports the following three partitioning methods: List, Range, and Hash.

    The definition of a partition in MySQL mode is different from that in Oracle mode. So, the values of the following fields vary in different modes. You need to specify the following fields based on the selected partitioning method.

Field Description
Partitioning Method Specifies the partitioning method. The partitioning methods supported in MySQL mode are different from those in Oracle mode.
- Range partitioning: Multiple rows with column values in an ordered, continuous and non-overlapping range are assigned to a partition.
- List partitioning: A table is partitioned based on the enumeration values.
- Hash partitioning: A table is partitioned based on a given number of partitions. For a table that stores data without a clear pattern or range, you can use hash partitioning to randomly distribute values of the partition column to different partitions based on the HASH algorithm.
- Key partitioning: This partitioning method is similar to HASH partitioning. The difference is that key partitioning only supports computation of one or more columns, and the MySQL server provides its own hash function. At least one INT type column is required for Key partitioning.
Field The column that is used as the partition key.
Expression Partitions are divided based on the return value of the expression. The partition expression is not supported in Oracle mode.
Partition Based on the value specified for Partitioning Method, you may need to specify information such as Partition Name, Partition Quantity, Upper limit of the range, and Enumeration Value.
Note
- When selecting the Range partitioning method, if the table contains a large amount of data, you can fill in MAXVALUE in Upper limit of the range, which means that the upper limit of the range is not set.
- You can add multiple partitions and drag the partitions to adjust their order.

Step 4: Set the index.

If a table contains a large amount of data, you can use indexes to accelerate data queries. An index is a data structure that pre-sorts the values of one or more columns in a table. By using indexes, you can directly locate records that meet the conditions.

The following figure and table show the information that you need to specify when you set the index.

Step 4

Field Description
Index Name The name of the index.
Index Range The default value is GLOBAL, which indicates a global index. You can set this parameter to LOCAL only for tables with partitions. The value LOCAL indicates a local index.
Index Type Only BTree is supported.
Optional Field The columns to be indexed. Pay attention to the order of the indexed columns.
Unique Specifies whether the index is unique. In other words, the index is used to ensure that the constraint is unique.

The index setting section also provides three buttons.

Button Description
Create Click this button to add an index.
Edit Click this button to edit the selected index. You can also directly double-click a cell to edit it.
Delete Click this button to delete the selected index.

Step 5: Set constraints.

Constraints are used to specify data rules for a table. A data operation that violates the constraints will be terminated.

Step 5

ODC supports the following four table constraints:

  • Primary Key Constraint: defines a primary key to uniquely identify each row of data in the table. A primary key constraint can be a field or a group of fields. You can set only one primary key constraint for a table, and you cannot edit the constraint after it is configured.

  • Unique Constraint: ensures that the data in a field or a group of fields is unique in the table. You can set multiple unique constraints in one table.

  • Foreign Key Constraint: associates one or more columns in two tables. A foreign key constraint is used to maintain the data consistency and integrity between associated tables. After you complete the setting of foreign key constraints, you cannot create new constraints or edit existing constraints.

  • Check Constraint: checks the data in the database based on the configured check rules when you edit the data. Data modification is allowed only after the check is passed. OceanBase Database supports Check Constraint only in Oracle mode.

OceanBase Database supports different constraints in MySQL and Oracle modes, and different constraints require different information. Therefore, you need to specify the required information based on the constraint you selected and the requirements on the page.

Field Description
Constraint Name The name of the constraint.
Column Information The field or a group of fields specified as the constraint.
Trigger State Specifies whether to enable the created constraint. In some cases, you may need to temporarily disable the constraints. For example, when you import a large amount of data, you can disable constraints to improve the import efficiency. This field is valid only in Oracle mode.
Deferrable Supports three types of delay status. Valid values: Verify Now , Non-deferrable , and Delayed Verification. This field is valid only in Oracle mode.
Associated Schema The schema where the associated table is located when Foreign Key Constraint is used. The associated table is the parent table. This field is valid only in Oracle mode.
Associated Database The database where the associated table is located when Foreign Key Constraint is used. The associated table is the parent table. This field is valid only in MySQL mode.
Associated Table The associated table when Foreign Key Constraint is used. The associated table is the parent table.
Associated Field The associated field when Foreign Key Constraint is used. The associated field is in the parent table.
Delete Specifies the action to be performed on the current table when the data in the associated table is deleted. The current table is the child table, and the associated table is the parent table. The following four types of action are supported: CASCADE, NO ACTION, RESTRICT, and SET NULL. OceanBase Database supports different foreign key actions in MySQL and Oracle modes.
- In MySQL mode, OceanBase Database allows you to specify CASCADE, NO ACTION, RESTRICT, and SET NULL.
- In Oracle mode, OceanBase Database allows you to specify CASCADE, NO ACTION, and SET NULL.
Notice
At present, OceanBase Database does not support SET NULL.
For more information about the syntax, see CREATE TABLE, or the official documentation of MySQL or Oracle.
Update Specifies the action to be performed on the current table when the data in the associated table is updated. The current table is the child table, and the associated table is the parent table. The following four types of action are supported: CASCADE, NO ACTION, RESTRICT, and SET NULL. OceanBase Database supports different foreign key actions in MySQL and Oracle modes.
- In MySQL mode, OceanBase Database allows you to specify CASCADE, NO ACTION, RESTRICT, and SET NULL.
- In Oracle mode, OceanBase Database allows you to specify NO ACTION.
Notice
At present, OceanBase Database does not support SET NULL.
For more information about the syntax, see CREATE TABLE, or the official documentation of MySQL or Oracle.
Check Condition Specifies the check rules for data verification when Check Constraint is enabled. This field is valid only in Oracle mode.

The constraint setting section also provides three buttons.

Button Description
Create Click this button to add a constraint.
Edit Click this button to edit the selected constraint. You can also directly double-click a cell to edit it.
Delete Click this button to delete the selected constraint.

Step 6: Verify the SQL statement.

Step 6

Click Submit to go to the SQL Confirmation page.

You can edit the SQL statement on the SQL Confirmation page. Syntax:

CREATE TABLE table_name (column_name column_type, column_name column_type,.......);
Parameter Description
CREATE TABLE The key word that indicates the creation ofa table with a specified name. You must have the privileges to create tables.
table_name The name of the table. The table name must conform to the identifier naming rules.
column_name column_type The name and data type of the column or field in the table. To create multiple columns, separate the tuple with commas (,).

Step 7: Complete the table creation.

Click Run. After the table is created, the employee table appears in the table list in the left-side navigation pane.

Step 7.1

Note
To manage a table, right-click the table name in the left-side navigation pane, and select the required operation from the context menu, which provides the following options: View, Create, **Single Table Import **, Single Table Export, Download, Mock Data, Open SQL Window, Copy, Rename, Delete, and Refresh.

For more information, see Manage table data.

You can use the SELECT statement to query data in the new table.

Syntax:

SELECT
  column_name,
  column_name
FROM
  table_name [WHERE Clause] [LIMIT N] [ OFFSET M]
Parameter Description
SELECT The key word that indicates the name of the statement. You can use the SELECT statement to read one or more records.
column_name The name of the column to be queried. You can use an asterisk (*) to query all columns
WHERE The key word of the condition clause.
LIMIT The number of records to be returned.
OFFSET The data offset from which the SELECT statement starts to query. The default offset is 0.

Example:

SELECT `emp_no`, `birthdate`, `name`, `gender` FROM `employee`;

Step 7.2

Related topics

  • Create a view
  • Create a function
  • Create a stored procedure
  • Create a sequence
  • Create a program package
  • Create a trigger
  • Create a type
  • Create a synonym

Previous topic

Session management
Last

Next topic

Create a table
Next
What is on this page
Overview
Procedure
Step 1: Specify the basic information.
Step 2: Set columns.
Step 3: Set partitioning rules.
Step 4: Set the index.
Step 5: Set constraints.
Step 6: Verify the SQL statement.
Step 7: Complete the table creation.
Related topics