tencent cloud

TDSQL Boundless

Release Notes
Product Introduction
Overview
Scenarios
Product Architecture
Instance Types
Compatibility Notes
Usage specification recommendations
Kernel Features
Kernel Overview
Kernel Version Release Notes
Functionality Features
Performance Features
Billing
Billing Overview
Purchase Method
Pricing Details
Renewal
Overdue Payments
Refund
Getting Started
Creating an Instance
Connect to Instances
User Guide
Data Migration
Data Subscription
Instance Management
Parameter Configuration
Account Management
Security Group
Backup and Restoration
Database Auditing
Tag Management
Use Cases
Technical Evolution and Usage Practices of Online DDL
Lock Mechanism Analysis and Troubleshooting Practices
Data Intelligent Scheduling and Related Practices for Performance Optimization
TDSQL Boundless Selection Guide and Practical Tutorial
Developer Guide
Developer Guide (MySQL Compatibility Mode)
Developer Guide (HBase Compatibility Mode)
Performance Tuning
Performance Tuning Overview
SQL Tuning
DDL Tuning
Performance White Paper
Performance Overview
TPC-C Test
Sysbench Test
API Documentation
History
Introduction
API Category
Making API Requests
Instance APIs
Security Group APIs
Task APIs
Backup APIs
Rollback APIs
Parameter APIs
Database APIs
Data Types
Error Codes
General Reference
System Architecture
SQL Reference
Database Parameter Description
TPC-H benchmark data model reference
Error Code Information
Security and Compliance
FAQs
Agreements
Service Level Agreement
Terms of Service
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

Creating a Database

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-03-06 18:48:24

Syntax

CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name
[create_option] ...
create_option: [DEFAULT] {
CHARACTER_SET [=] charset_name
| COLLATE [=] collation_name
| ENCRYPTION [=] {'Y' | 'N'}
}
CREATE DATABASE: creates a database with the given name. If the database already exists and IF NOT EXISTS is not specified, an error will be reported.
create_option : Specifies a property of the database. The database properties are stored in the data dictionary.
CHARACTER_SET : Specifies the default character set for the database.
COLLATE: Specifies the default collation for the database.
ENCRYPTION: Specifies the default encryption method for the database. Tables in the database will inherit this encryption method. Allowed values are 'Y' (enable encryption) and 'N' (disable encryption). If the ENCRYPTION option is not specified, the system variable default_table_encryption is used as the default encryption method for the database.

Usage Limits and Specifications

Naming Conventions
Length limit: The database name must not exceed 64 characters.
Global Uniqueness: The database name must be globally unique within the TDSQL Boundless cluster.
Naming format: It is recommended to use the business_system_name_subsystem_name format, with tables within the same module sharing a common prefix.
Character requirements: Use lowercase English letters uniformly, and avoid Chinese naming and special symbols (except underscores).
Reserved word avoidance: SQL reserved keywords should be avoided as database names.
Configuration Specifications
Character Set Uniformity: All tables and fields in the same database should use the same character set to ensure consistency in character sets for application connections, databases, tables, and fields.
System Protection: Default databases in the system should not be used directly. It is recommended to create your own database using SQL statements.

Examples

# CREATE DATABASE db1; if it already exists, an error will be reported
CREATE DATABASE db1;

# CREATE DATABASE db2; if it already exists, do nothing
CREATE DATABASE IF NOT EXISTS db2;

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan