tencent cloud

TDSQL Boundless

CREATE DATABASE

Download
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-02-10 11:25:37

Description

This statement is used to create a database and can specify the default attributes of the database (such as the default character set and collation rules).

Permission Requirements

To execute the CREATE DATABASE statement to create a database, users need to have the global CREATE permission.

Syntax

CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] database_name
[database_option] ...

database_option:
[DEFAULT] {CHARACTER SET | CHARSET} [=] charset_name
| [DEFAULT] COLLATE [=] collate_name

Parameter Description

Parameter
Optional or Not
Description
IF NOT EXISTS
Optional
Indicates that if the database already exists, it will not be created. When a database is created, if the database exists and no IF NOT EXISTS is specified, an error will be reported.
database_name
Required
Specifies the name of the database to be created.
[DEFAULT] {CHARACTER SET | CHARSET} [=] charset_name
Optional
Sets the character set (charset) of the database.
[DEFAULT] COLLATE [=] collate_name
Optional
Sets the collation rules of the database.

Examples

tdsql [(none)]> CREATE DATABASE IF NOT EXISTS test1 DEFAULT CHARACTER SET utf8;
Query OK, 1 row affected

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백