Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Solutions
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Managed Service for ClickHouse
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Information about existing clusters
    • Creating clusters
    • How to connect to a database
    • Stopping and starting clusters
    • SQL queries in the management console
    • Changing cluster and database settings
    • Connecting external dictionaries
    • Adding your own geobase
    • Enabling machine learning models
    • Managing data format schemas
    • Connecting to DataLens
    • Changing ClickHouse versions
    • Managing ClickHouse hosts
    • Managing ZooKeeper hosts
    • Database management
    • Managing database users
    • Managing backups
    • Managing shards
    • Managing groups of shards
    • Deleting clusters
  • Use cases
    • Adding data to the database
    • Sharding tables
    • Using hybrid storage
    • Getting data from Managed Service for Apache Kafka®
  • Concepts
    • Relationship between service resources
    • Host classes
      • Active host classes
      • Archive
        • Before June 1, 2020
      • Using deprecated host classes
    • Network in Yandex Managed Service for ClickHouse
    • Quotas and limits
    • Storage types
    • Backups
    • Replication
    • Dictionaries
    • Sharding
    • Supported clients
    • ClickHouse versioning policy
  • Access management
  • Pricing policy
    • Current pricing policy
    • Archive
      • Before January 1, 2019
      • From January 1 to March 1, 2019
      • From March 1, 2019 to February 1, 2020
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • BackupService
      • ClusterService
      • DatabaseService
      • FormatSchemaService
      • MlModelService
      • ResourcePresetService
      • UserService
      • VersionsService
      • OperationService
    • REST
      • Overview
      • Backup
        • Overview
        • get
        • list
      • Cluster
        • Overview
        • addHosts
        • addShard
        • addZookeeper
        • backup
        • create
        • createExternalDictionary
        • createShardGroup
        • delete
        • deleteExternalDictionary
        • deleteHosts
        • deleteShard
        • deleteShardGroup
        • get
        • getShard
        • getShardGroup
        • list
        • listBackups
        • listHosts
        • listLogs
        • listOperations
        • listShardGroups
        • listShards
        • move
        • rescheduleMaintenance
        • restore
        • start
        • stop
        • streamLogs
        • update
        • updateShard
        • updateShardGroup
      • Database
        • Overview
        • create
        • delete
        • get
        • list
      • FormatSchema
        • Overview
        • create
        • delete
        • get
        • list
        • update
      • MlModel
        • Overview
        • create
        • delete
        • get
        • list
        • update
      • ResourcePreset
        • Overview
        • get
        • list
      • User
        • Overview
        • create
        • delete
        • get
        • grantPermission
        • list
        • revokePermission
        • update
      • Versions
        • Overview
        • list
      • Operation
        • Overview
        • get
  • Questions and answers
    • General questions
    • Questions about ClickHouse
    • All questions on the same page
  1. Step-by-step instructions
  2. Database management

Database management

  • Managing databases using SQL
  • Getting a list of cluster databases
  • Creating a database
  • Deleting a database

You can add and remove databases, as well as view information about them.

There are two ways to manage cluster databases:

  • Yandex.Cloud standard interfaces (CLI, API, or management console). Choose this method if you want to use all the features of the Yandex.Cloud managed service.
  • SQL queries to the cluster. Choose 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 using SQL

To manage databases using SQL, create a cluster via the API with the sqlDatabaseManagement setting enabled. In this cluster:

  • Databases can only be managed using SQL.
  • Management using Yandex.Cloud standard interfaces (CLI, API, or management console) isn't possible.
  • Users are managed under the admin account. The password for this account is set when creating a cluster.

To learn more about managing databases using SQL, see the documentation for ClickHouse.

Getting a list of cluster databases

Management console
CLI
API
SQL
  1. Go to the folder page and select Managed Service for ClickHouse.
  2. Click on the name of the cluster you need and select the Databases tab.

If you don't have the Yandex.Cloud command line interface yet, install and initialize it.

The folder specified in the CLI profile is used by default. 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>

The cluster name can be requested with a list of folder clusters.

To get a list of cluster databases, use the list method.

  1. Connect to the cluster using the admin account.

  2. Get a list of databases:

    SHOW DATABASES;
    

Creating a database

The number of databases in a cluster is unlimited.

Management console
CLI
API
SQL
  1. Go to the folder page and select Managed Service for ClickHouse.
  2. Click on the name of the cluster you need.
  3. Select the Databases tab.
  4. Click Add.
  5. Enter a name for the database and click Add.

Note

Database names may consist of Latin letters, numbers, dashes, and underscores. The maximum name length is 63 characters. You can't create a database named default.

If you don't have the Yandex.Cloud command line interface yet, install and initialize it.

The folder specified in the CLI profile is used by default. 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 <database name>
    --cluster-name <cluster name>

Managed Service for ClickHouse runs the create database operation.

Note

Database names may consist of Latin letters, numbers, dashes, and underscores. The maximum name length is 63 characters. You can't create a database named default.

The cluster name can be requested with a list of folder clusters.

You can create a new database in a cluster using the create method.

  1. Connect to the cluster using the admin account.

  2. Create a database:

    CREATE DATABASE <database name>;
    

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

Deleting a database

Management console
CLI
API
SQL
  1. Go to the folder page and select Managed Service for ClickHouse.
  2. Click on the name of the cluster you need and select the Databases tab.
  3. Click in the line of the necessary DB and select Delete.

If you don't have the Yandex.Cloud command line interface yet, install and initialize it.

The folder specified in the CLI profile is used by default. 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 <database name>
     --cluster-name=<cluster name>

The cluster name can be requested with a list of folder clusters.

You can delete a database using the delete method.

  1. Connect to the cluster using the admin account.

  2. Delete the database:

    DROP DATABASE <database name>;
    

To learn more about deleting objects, see the documentation forClickHouse.

Warning

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

In this article:
  • Managing databases using SQL
  • Getting a list of cluster databases
  • Creating a database
  • Deleting a database
Language / Region
Careers
Privacy policy
Terms of use
Brandbook
© 2021 Yandex.Cloud LLC