Updated on 2025-04-14 GMT+08:00

Creating a ClickHouse Database

This section describes the sample code for creating a ClickHouse database.

Run the on cluster statement to create a database whose name is the value of databaseName in Table 1 in the cluster.

The following is an example of a generation fragment:
private void createDatabase(String databaseName, String clusterName) throws Exception  {    
     String createDbSql = "create database if not exists " + databaseName + " on cluster " + clusterName;    
     util.exeSql(createDbSql);
}