Yandex Cloud
Search
Contact UsTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Yandex Managed Service for ClickHouse®
  • Getting started
    • All guides
      • SQL queries in Yandex WebSQL
      • Database management
      • DB user management
  • Access management
  • Pricing policy
  • Terraform reference
  • Yandex Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

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

Database management in Managed Service for ClickHouse®

Written by
Yandex Cloud
Updated at December 17, 2025
  • Database management via SQL
  • Getting a list of cluster databases
  • Creating a database
  • Deleting a database

Managed Service for ClickHouse® provides two methods for managing cluster databases:

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

Database management via SQLDatabase management via SQL

To enable this management method, select User management via SQL and Managing databases via SQL when creating or reconfiguring your cluster.

In a cluster with enabled database management via SQL:

  • You cannot manage databases and users via the native Yandex Cloud interfaces, such as the CLI, API, and management console.
  • You cannot enable user or database management via the native Yandex Cloud interfaces.
  • The existing users, user settings, and databases created with the native Yandex Cloud interfaces will remain unchanged.
  • Use the admin account for management. You set the admin 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, select the folder the cluster is in.
  2. Go to Managed Service for ClickHouse.
  3. Click the cluster name and select the Databases tab.

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

By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.

To get a list of cluster databases, run this command:

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

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

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

    export IAM_TOKEN="<IAM_token>"
    
  2. Call the Database.List method, for instance, via the following cURL request:

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

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

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

  1. Get an IAM token for API authentication and put it into an 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. Call the DatabaseService.List method, for instance, via the following gRPCurl request:

    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 the list of clusters in the folder.

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

  1. Connect to your cluster as admin.

  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.

To learn more about limits, see Quotas and limits.

Management console
CLI
Terraform
REST API
gRPC API
SQL
  1. In the management console, select the folder the cluster is in.

  2. Go to Managed Service for ClickHouse.

  3. Click the cluster name.

  4. Select the Databases tab.

  5. Click Create database.

  6. Enter a name for the database.

    Note

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

  7. Select the database engine:

    • By default, Atomic supports the non-blocking DROP TABLE and RENAME TABLE operations and atomic EXCHANGE TABLES operations.

    • Replicated supports table metadata replication across all database replicas. The set of tables and their schemas will be the same for all replicas.

      It is only available in replicated clusters.

    You can only set the engine when creating a database and cannot change it later.

  8. Click Create.

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

By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.

Run the database create command, providing a name for the new database:

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

Note

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

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

Managed Service for ClickHouse® will start creating the database.

  1. Open the current Terraform configuration file describing your infrastructure.

    For information on how to create such a file, see Creating a cluster.

  2. Add the yandex_mdb_clickhouse_database resource:

    resource "yandex_mdb_clickhouse_database" "<DB_name>" {
      cluster_id = "<cluster_ID>"
      name       = "<DB_name>"
    }
    

    Note

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

    When creating both a cluster and a database with Terraform at the same time, specify a name for the new cluster rather than cluster ID in the yandex_mdb_clickhouse_database resource:

    
    resource "yandex_mdb_clickhouse_cluster" "<cluster_name>" {
      name = "<cluster_name>"
      ...
    }
    
    resource "yandex_mdb_clickhouse_database" "<DB_name>" {
      cluster_id = yandex_mdb_clickhouse_cluster.<cluster_name>.id
      name       = "<DB_name>"
    }
    
  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 this Terraform provider guide.

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

    export IAM_TOKEN="<IAM_token>"
    
  2. Call the Database.Create method, for instance, via the following cURL request:

    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>",
                    "engine": "<database_engine>"
                  }
                }'
    

    Where:

    • databaseSpec.name: Database name.

      Note

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

    • databaseSpec.engine: Database engine. The possible values are:

      • DATABASE_ENGINE_ATOMIC (default): Atomic engine; supports non-blocking DROP TABLE and RENAME TABLE queries, and atomic EXCHANGE TABLES queries.

      • DATABASE_ENGINE_REPLICATED: Replicated engine; supports table metadata replication across all database replicas. The set of tables and their schemas will be the same for all replicas.

        It is only available in replicated clusters.

      • DATABASE_ENGINE_UNSPECIFIED: This value will set the default engine, i.e., DATABASE_ENGINE_ATOMIC.

      You set the engine when creating a database and cannot change it for this database.

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

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

  1. Get an IAM token for API authentication and put it into an 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. Call the DatabaseService.Create method, for instance, via the following gRPCurl request:

    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>",
                "engine": "<database_engine>"
              }
            }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.clickhouse.v1.DatabaseService.Create
    

    Where:

    • database_spec.name: Database name.

      Note

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

    • database_spec.engine: Database engine. The possible values are:

      • DATABASE_ENGINE_ATOMIC (default): Atomic engine; supports non-blocking DROP TABLE and RENAME TABLE queries, and atomic EXCHANGE TABLES queries.

      • DATABASE_ENGINE_REPLICATED: Replicated engine; supports table metadata replication across all database replicas. The set of tables and their schemas will be the same for all replicas.

        It is only available in replicated clusters.

      • DATABASE_ENGINE_UNSPECIFIED: This value will set the default engine, i.e., DATABASE_ENGINE_ATOMIC.

      You set the engine when creating a database and cannot change it for this database.

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

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

  1. Connect to your cluster as admin.

  2. Create a database:

    CREATE DATABASE <DB_name>;
    

    Note

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

To learn more about creating databases, see this ClickHouse® guide.

Deleting a databaseDeleting a database

Management console
CLI
Terraform
REST API
gRPC API
SQL
  1. In the management console, select the folder the cluster is in.
  2. Go to Managed Service for ClickHouse.
  3. Click the cluster name and select the Databases tab.
  4. Click in the relevant database row and select Delete.

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

By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.

To delete a database, run this command:

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

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

  1. Open the current Terraform configuration file describing your infrastructure.

    For information on how to create such a file, see Creating a cluster.

  2. Delete the yandex_mdb_clickhouse_database resource with the name of the database you are deleting.

  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 this Terraform provider guide.

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

    export IAM_TOKEN="<IAM_token>"
    
  2. Call the Database.Delete method, for instance, via the following cURL request:

    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 the folder, and the database name, with the list of databases in the cluster.

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

  1. Get an IAM token for API authentication and put it into an 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. Call the DatabaseService.Delete method, for instance, via the following gRPCurl request:

    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 the folder, and the database name, with the list of databases in the cluster.

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

  1. Connect to your cluster as admin.

  2. Delete the database:

    DROP DATABASE <DB_name>;
    

Learn more about deleting objects in this ClickHouse® guide.

Warning

Before creating a new database with the same name, wait for the delete operation to complete. Otherwise, the original database will be restored. You can get the operation status with the 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
© 2025 Direct Cursus Technology L.L.C.