CREATE DATABASE
This section describes the syntax of a CREATE DATABASE statement that is used to create a database in ClickHouse.
CREATE DATABASE
CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER default_cluster];
Parameter | Description |
|---|---|
db_name | 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 default_cluster | The specified cluster name. The default value is default_cluster. |

You can run the following statement to obtain the cluster name from the cluster field:
select cluster,shard_num,replica_num,host_name from system.clusters;
Usage Example
- Create a database named demo.
create database demo ON CLUSTER default_cluster;
- View the created database.
host-172-16-30-9 :) show databases; SHOW DATABASES Query id: ced1af23-0286-40cc-9c7a-ccbca41178d8 ┌─name───────────────┐ │ INFORMATION_SCHEMA │ │ default │ │ demo │ │ information_schema │ │ system │ └────────────────────┘ 5 rows in set. Elapsed: 0.002 sec.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.

