Help Center/
Distributed Database Middleware/
User Guide (Kuala Lumpur Region)/
SQL Syntax/
DDL/
Creating a Table
Updated on 2022-08-17 GMT+08:00
Creating a Table
Database and Table Sharding
The following is an example when HASH is used for database sharding and MOD_HASH for table sharding:
CREATE TABLE tbpartition_tbl ( id int NOT NULL AUTO_INCREMENT COMMENT 'Primary key ID', name varchar(128), PRIMARY KEY(id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci DBPARTITION BY HASH(id) TBPARTITION BY mod_hash(name) tbpartitions 8;
Database Sharding
The following is an example when HASH is used:
CREATE TABLE dbpartition_tbl ( id int NOT NULL AUTO_INCREMENT COMMENT 'Primary key ID', name varchar(128), PRIMARY KEY(id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci DBPARTITION BY HASH(id);
Creating a Broadcast Table
The following is an example statement:
CREATE TABLE broadcast_tbl ( id int NOT NULL AUTO_INCREMENT COMMENT 'Primary key ID', name varchar(128), PRIMARY KEY(id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci BROADCAST;
Creating a Table When Sharding Is not Used
The following is an example statement:
CREATE TABLE single( id int NOT NULL AUTO_INCREMENT COMMENT 'Primary key ID', name varchar(128), PRIMARY KEY(id) );
Parent topic: DDL
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot