Help Center/ CloudTable Service/ FAQs/ Data Read/Write/ What Should I Do If a Database Missing Error Occurs When a Table Is Created in the ClickHouse Cluster?
Updated on 2024-04-30 GMT+08:00

What Should I Do If a Database Missing Error Occurs When a Table Is Created in the ClickHouse Cluster?

Symptom

When a table is created, the system displays a message indicating that the database does not exist on another node.

Figure 1 Execution results

Possible Causes

A database is created only on one node when the cluster is created.

Solutions

Create a database on another code or use another command to create one on each node.

Method 1:

  1. Creates a database.

    create database demo;

    Use the demo database.

    use demo;

  2. Create the test table. The result shown in Figure 1 is displayed. The demo database does not exist on other nodes.

    CREATE TABLE demo.test ON CLUSTER default_cluster(`EventDate` DateTime, `id` UInt64)ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/default/test', '{replica}') PARTITION BY toYYYYMM(EventDate) ORDER BY id;

  3. Create a database demo on another node and create a table. If the information shown in the following figure is displayed, no error occurs.

    Figure 2 Successful execution

Method 2:

  1. Delete the existing database and use the following command to create a database on each node.

    create database demo ON CLUSTER default_cluster;

  2. Create a table and error message shown in Figure 1 is not displayed.