Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Managed Service for ClickHouse®
  • Getting started
    • All guides
      • SQL queries in Yandex WebSQL
      • Managing databases
      • DB user management
  • Access management
  • Terraform reference
  • Yandex Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

  • Managing databases via SQL
  • Getting a list of cluster databases
  • Creating a database
  • Deleting a database
  1. Step-by-step guides
  2. Databases
  3. Managing databases

Managing databases in Managed Service for ClickHouse®

Written by
Yandex Cloud
Updated at May 5, 2025
  • Managing databases via SQL
  • Getting a list of cluster databases
  • Creating a database
  • Deleting a database

Managed Service for ClickHouse® provides two ways for you to manage cluster databases:

  • Using native Yandex Cloud interfaces, such as the CLI, API, or management console. Select this method if you wish to create and delete cluster databases using Yandex Managed Service for ClickHouse® features.
  • SQL queries to the cluster. Select this method if you want to use an existing solution for creating and managing databases, or if you need MySQL® database support in Managed Service for ClickHouse®.

Managing databases via SQLManaging databases via SQL

To enable management, activate the User management via SQL and Managing databases via SQL options when creating or reconfiguring a cluster.

In a cluster with DB management via SQL enabled:

  • Database and user management using the standard Yandex Cloud interfaces (CLI, API, management console) is unavailable.
  • You cannot enable user or database management using the standard Yandex Cloud interfaces.
  • The existing users as well as user and database settings made with the standard Yandex Cloud interfaces will be saved.
  • User management is performed using the admin account. You set its password when selecting the User management via SQL and Managing databases via SQL options.

Getting a list of cluster databasesGetting a list of cluster databases

Management console
CLI
REST API
gRPC API
SQL
  1. In the management console, go to the folder page and select Managed Service for ClickHouse.
  2. Click the name of the cluster you need and select the Databases tab.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To get a list of databases in a cluster, run the command:

yc managed-clickhouse database list \
   --cluster-name=<cluster_name>

You can request the cluster name with a list of clusters in the folder.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Use the Database.List method and send the following request, e.g., via cURL:

    curl \
      --request GET \
      --header "Authorization: Bearer $IAM_TOKEN" \
      --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/clusters/<cluster_ID>/databases'
    

    You can get the cluster ID with a list of clusters in the folder.

  3. View the server response to make sure the request was successful.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Clone the cloudapi repository:

    cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
    

    Below, we assume the repository contents are stored in the ~/cloudapi/ directory.

  3. Use the DatabaseService.List call and send the following request, e.g., via gRPCurl:

    grpcurl \
      -format json \
      -import-path ~/cloudapi/ \
      -import-path ~/cloudapi/third_party/googleapis/ \
      -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/database_service.proto \
      -rpc-header "Authorization: Bearer $IAM_TOKEN" \
      -d '{
            "cluster_id": "<cluster_ID>"
          }' \
      mdb.api.cloud.yandex.net:443 \
      yandex.cloud.mdb.clickhouse.v1.DatabaseService.List
    

    You can get the cluster ID with a list of clusters in the folder.

  4. View the server response to make sure the request was successful.

  1. Connect to a cluster using the admin account.

  2. Get a list of databases:

    SHOW DATABASES;
    

Creating a databaseCreating a database

Note

You can create a maximum of 1000 databases in each cluster.

Management console
CLI
Terraform
REST API
gRPC API
SQL
  1. In the management console, go to the folder page and select Managed Service for ClickHouse.

  2. Click the cluster name.

  3. Select the Databases tab.

  4. Click Create database.

  5. Enter the database name and click Create.

    Note

    The DB name may contain Latin letters, numbers, and underscores. The name may be up to 63 characters long. You cannot create a database named default.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

Run the create database command and set the name of the new database:

yc managed-clickhouse database create <DB_name> \
   --cluster-name=<cluster_name>

Note

The DB name may contain Latin letters, numbers, and underscores. The name may be up to 63 characters long. You cannot create a database named default.

You can request the cluster name with a list of clusters in the folder.

Managed Service for ClickHouse® runs the create database operation.

  1. Open the current Terraform configuration file with an infrastructure plan.

    For more information about creating this file, see Creating clusters.

  2. Add the database DB description block to the Managed Service for ClickHouse® cluster description:

    resource "yandex_mdb_clickhouse_cluster" "<cluster_name>" {
      ...
      database {
        name = "<DB_name>"
      }
    }
    

    Note

    The DB name may contain Latin letters, numbers, and underscores. The name may be up to 63 characters long. You cannot create a database named default.

  3. Make sure the settings are correct.

    1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.

    2. Run this command:

      terraform validate
      

      Terraform will show any errors found in your configuration files.

  4. Confirm updating the resources.

    1. Run this command to view the planned changes:

      terraform plan
      

      If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. Wait for the operation to complete.

For more information, see the Terraform provider documentation.

Time limits

A Terraform provider sets the timeout for Managed Service for ClickHouse® cluster operations:

  • Creating a cluster, including by restoring one from a backup: 60 minutes.
  • Editing a cluster: 90 minutes.
  • Deleting a cluster: 30 minutes.

Operations exceeding the set timeout are interrupted.

How do I change these limits?

Add the timeouts block to the cluster description, for example:

resource "yandex_mdb_clickhouse_cluster" "<cluster_name>" {
  ...
  timeouts {
    create = "1h30m" # 1 hour 30 minutes
    update = "2h"    # 2 hours
    delete = "30m"   # 30 minutes
  }
}
  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Use the Database.Create method and send the following request, e.g., via cURL:

    curl \
        --request POST \
        --header "Authorization: Bearer $IAM_TOKEN" \
        --header "Content-Type: application/json" \
        --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/clusters/<cluster_ID>/databases' \
        --data '{
                  "databaseSpec": {
                    "name": "<DB_name>"
                  }
                }'
    

    Note

    The DB name may contain Latin letters, numbers, and underscores. The name may be up to 63 characters long. You cannot create a database named default.

    You can get the cluster ID with a list of clusters in the folder.

  3. View the server response to make sure the request was successful.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Clone the cloudapi repository:

    cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
    

    Below, we assume the repository contents are stored in the ~/cloudapi/ directory.

  3. Use the DatabaseService.Create call and send the following request, e.g., via gRPCurl:

    grpcurl \
        -format json \
        -import-path ~/cloudapi/ \
        -import-path ~/cloudapi/third_party/googleapis/ \
        -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/database_service.proto \
        -rpc-header "Authorization: Bearer $IAM_TOKEN" \
        -d '{
              "cluster_id": "<cluster_ID>",
              "database_spec": {
                "name": "<DB_name>"
              }
            }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.clickhouse.v1.DatabaseService.Create
    

    Note

    The DB name may contain Latin letters, numbers, and underscores. The name may be up to 63 characters long. You cannot create a database named default.

    You can get the cluster ID with a list of clusters in the folder.

  4. View the server response to make sure the request was successful.

  1. Connect to a cluster using the admin account.

  2. Create a database:

    CREATE DATABASE <DB_name>;
    

    Note

    The DB name may contain Latin letters, numbers, and underscores. The name may be up to 63 characters long. You cannot create a database named default.

To learn more about creating databases, see the ClickHouse® documentation.

Deleting a databaseDeleting a database

Management console
CLI
Terraform
REST API
gRPC API
SQL
  1. In the management console, go to the folder page and select Managed Service for ClickHouse.
  2. Click the cluster name and open the Databases tab.
  3. Click in the required DB row and select Delete.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To delete a database, run the command:

yc managed-clickhouse database delete <DB_name> \
   --cluster-name=<cluster_name>

You can request the cluster name with a list of clusters in the folder.

  1. Open the current Terraform configuration file with an infrastructure plan.

    For more information about creating this file, see Creating clusters.

  2. Delete the database DB description block from the Managed Service for ClickHouse® cluster description.

  3. Make sure the settings are correct.

    1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.

    2. Run this command:

      terraform validate
      

      Terraform will show any errors found in your configuration files.

  4. Confirm updating the resources.

    1. Run this command to view the planned changes:

      terraform plan
      

      If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. Wait for the operation to complete.

For more information, see the Terraform provider documentation.

Time limits

A Terraform provider sets the timeout for Managed Service for ClickHouse® cluster operations:

  • Creating a cluster, including by restoring one from a backup: 60 minutes.
  • Editing a cluster: 90 minutes.
  • Deleting a cluster: 30 minutes.

Operations exceeding the set timeout are interrupted.

How do I change these limits?

Add the timeouts block to the cluster description, for example:

resource "yandex_mdb_clickhouse_cluster" "<cluster_name>" {
  ...
  timeouts {
    create = "1h30m" # 1 hour 30 minutes
    update = "2h"    # 2 hours
    delete = "30m"   # 30 minutes
  }
}
  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Use the Database.Delete method and send the following request, e.g., via cURL:

    curl \
        --request DELETE \
        --header "Authorization: Bearer $IAM_TOKEN" \
        --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/clusters/<cluster_ID>/databases/<DB_name>'
    

    You can get the cluster ID with the list of clusters in your folder and the DB name, with the list of databases in your cluster.

  3. View the server response to make sure the request was successful.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Clone the cloudapi repository:

    cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
    

    Below, we assume the repository contents are stored in the ~/cloudapi/ directory.

  3. Use the DatabaseService.Delete call and send the following request, e.g., via gRPCurl:

    grpcurl \
        -format json \
        -import-path ~/cloudapi/ \
        -import-path ~/cloudapi/third_party/googleapis/ \
        -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/database_service.proto \
        -rpc-header "Authorization: Bearer $IAM_TOKEN" \
        -d '{
              "cluster_id": "<cluster_ID>",
              "database_name": "<DB_name>"
            }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.clickhouse.v1.DatabaseService.Delete
    

    You can get the cluster ID with the list of clusters in your folder and the DB name, with the list of databases in your cluster.

  4. View the server response to make sure the request was successful.

  1. Connect to a cluster using the admin account.

  2. Delete the database:

    DROP DATABASE <DB_name>;
    

To learn more about deleting objects, see the ClickHouse® documentation.

Warning

Before creating a new database with the same name, wait for the delete operation to complete, otherwise the database being deleted will be restored. Operation status can be obtained with a list of cluster operations.

ClickHouse® is a registered trademark of ClickHouse, Inc.

Was the article helpful?

Previous
SQL queries in Yandex WebSQL
Next
DB user management
Yandex project
© 2025 Yandex.Cloud LLC