This topic describes the syntax of a CREATE DATABASE statement that is used to create a database in ApsaraDB for ClickHouse.

The following code shows the syntax of a CREATE DATABASE statement:

CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster];
Parameter description
  • db_name: the name of the database. A database name can be up to 64 characters in length and can contain letters, digits, and underscores (_). The database name must start with a lowercase letter and cannot contain consecutive underscores (_).
    Note You cannot use the word system as the database name because system is reserved as the name of the built-in database.
  • IF NOT EXISTS: You can add the IF NOT EXISTS keyword phrase to a CREATE DATABASE statement. In this case, if the name specified in the statement has been used by an existing database, no database is created and no error is returned.
  • ON CLUSTER cluster: specifies the name of the cluster in which you want to create a database.

Example:

CREATE DATABASE db_001 ON CLUSTER default;