tencent cloud

TDSQL Boundless

Creating a Database

PDF
フォーカスモード
フォントサイズ
最終更新日: 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;

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック