Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Show all

Table Design

Updated on 2025-02-12 GMT+08:00
  • All created MySQL tables must use the InnoDB engine.
  • The decimal type must be DECIMAL. Do not use FLOAT or DOUBLE.

    FLOAT and DOUBLE have lower precision than DECIMAL and may cause rounding errors. If a value to be stored is beyond the range of DECIMAL, split the value into INTEGER and DECIMAL parts and store them separately.

  • The following reserved words cannot be used: DESC, RANGE, MATCH, and DELAYED.

    For details about the keywords and reserved words of MySQL Community Edition 8.0, see Keywords and Reserved Words.

    In addition to the keywords and reserved words of MySQL Community Edition 8.0, some other keywords and reserved words are added to TaurusDB. Do not use these keywords and reserved words when naming objects.

    Table 1 lists the new keywords and reserved words in TaurusDB.
    Table 1 New keywords and reserved words in TaurusDB

    Reserved Word

    Related Scenario

    EXTRA_HEALTH

    High availability

    PBS

    Backup and restoration

    REDO

    Primary/standby replication

    SLICEID

    Shared storage

    SLOWIO

    Shared storage

    SPACEUSAGE

    Shared storage

    RDS_INSTANT

    Recycle bin

    RECYCLE_BIN

    Recycle bin

    RDS_RECYCLE

    Recycle bin

    RDS_TAC

    Recycle bin

    RDS_GDB_CTRL

    RegionlessDB

  • Every data table must have a primary key, which can be either an ordered and unique field related to business or an auto-increment field unrelated to business.
  • Each table field must have a default value and NOT NULL. If the field is the numeric type, use 0 as its default value. If the field is the character type (such as VARCHAR), use an empty string (").
    NOTE:

    The absence of a primary key may cause slow execution of the primary database and replication latency.

  • You are not advised to use partitioned tables. If necessary, use multiple independent tables.
    NOTE:

    Disadvantages of partitioned tables:

    • All partitions will be locked during DDL operations. As a result, operations on the partitions will be blocked.
    • When a partitioned table contains a large amount of data, it is difficult and risky to perform DDL or other O&M operations on the table.
    • Partition tables are seldom used, which may cause unknown risks.
    • When a single server is poor in performance, splitting a partitioned table is expensive.
    • When all partitions are accessed due to improper operations on a partitioned table, severe performance problems may occur.
  • Each table contains two DATETIME fields: CREATE_TIME and UPDATE_TIME.
    NOTE:

    You can obtain the required data from a data warehouse based on these two fields without consulting services.

    When an exception occurs in the database, you can use the two fields to determine the time when the data is inserted and updated. In extreme cases, you can determine whether to restore data based on the fields.

  • VARCHAR is a variable-length character data type. The length of VARCHAR cannot exceed 2,048.

    If the length of a field exceeds 2,048, define the field type as TEXT or create an independent table and use a primary key to associate the related tables. In this way, the index efficiency of other fields is not affected.

  • The length of a single row in a table cannot exceed 1,024 bytes.
  • The maximum number of fields in a single table is 50.
  • If the lengths of all strings are almost the same, use the fixed-length character strings.
  • On the premise of ensuring data consistency, cross-table redundant fields are allowed to avoid join queries and improve query performance.
    NOTE:

    Redundant fields must comply with the following rules:

    • Fields are not frequently modified.
    • Fields are not large VARCHAR and TEXT.
  • The data types with proper storage size can save database tablespace and index storage space while improving the search speed. LONG TEXT and BLOB are not recommended.
  • Ensure that all characters are stored and represented in UTF-8 or utf8mb4 encoding. Comments must be provided for tables and fields.
  • Avoid using large transactions.

    For example, if multiple SELECT and UPDATE statements are executed in a high-frequency transaction, the database concurrency capability is severely affected because resources such as locks held by the transaction can be released only when the transaction is rolled back or committed. In this case, data write consistency must also be considered.

  • Full-text indexes are not recommended because there are many limitations on them.
  • For ultra-large tables, you also need to comply with the following rules:
    • Use TINYINT, SMALLINT, and MEDIUM_INT as integer types instead of INT. If a value is non-negative, add UNSIGNED. Keep the field type as short as possible while meeting service evolution requirements.
    • Configure the VARCHAR length as needed.

      Example:

      CREATE TABLE T1 (A VARCHAR(255));

      After optimization:

      CREATE TABLE T1 (A VARCHAR(Length that meets service requirements));

    • Use enumerations or integers instead of strings.
    • Use TIMESTAMP instead of DATETIME.
    • Keep the number of fields in a single table below 20.
    • Avoid using UNIQUE. Programs can enforce the constraints.
    • Store IP addresses as integers.
    • Partition fields with strong sequence and add range conditions during queries to improve efficiency.
    • If there is obvious hot data and cold data, place the hot data in a separate partition.
    • Use a proxy instance to connect to a database. In scenarios that do not require high consistency, distribute read requests to read replicas. If you have a high volume of queries, adding read replicas can help speed them up.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback