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];

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.

The ON CLUSTER keyword phrase is used to specify the name of the cluster in which you want to create a database.

Example:

CREATE DATABASE db_001 ON CLUSTER default;