Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Managed Service for PostgreSQL
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Information about existing clusters
    • Creating clusters
    • Connecting to databases
    • Stop and start the cluster
    • SQL queries in the management console
    • Changing cluster and database settings
    • Connecting to DataLens
    • Managing PostgreSQL hosts
    • Database management
    • How to manage PostgreSQL extensions
    • Managing database users
    • Granting permissions and roles
    • Managing backups
    • Deleting clusters
    • Database migration to the Cloud
    • Creating a logical replica of Amazon RDS for PostgreSQL in Managed Service for PostgreSQL
  • Solutions
    • Creating a PostgreSQL cluster for 1C
  • Concepts
    • Relationship between service resources
    • Host classes
    • Network in Yandex Managed Service for PostgreSQL
    • Quotas and limits
    • Storage types
    • Backups
    • Assigning roles
    • Replication
    • Supported clients
  • 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
      • ResourcePresetService
      • UserService
      • OperationService
    • REST
      • Overview
      • Backup
        • Overview
        • get
        • list
      • Cluster
        • Overview
        • addHosts
        • backup
        • create
        • delete
        • deleteHosts
        • get
        • list
        • listBackups
        • listHosts
        • listLogs
        • listOperations
        • move
        • rescheduleMaintenance
        • restore
        • start
        • startFailover
        • stop
        • streamLogs
        • update
        • updateHosts
      • Database
        • Overview
        • create
        • delete
        • get
        • list
        • update
      • ResourcePreset
        • Overview
        • get
        • list
      • User
        • Overview
        • create
        • delete
        • get
        • grantPermission
        • list
        • revokePermission
        • update
      • Operation
        • Overview
        • get
  • Questions and answers
    • General questions
    • Questions about PostgreSQL
    • All questions on the same page
  1. Step-by-step instructions
  2. Database management

Database management

  • 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.

Getting a list of cluster databases

Management console
CLI
API
  1. Go to the folder page and select Managed Service for PostgreSQL.
  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-postgresql database list
     --cluster-name=<cluster name>

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

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

Creating a database

You can create an unlimited number of databases in each Managed Service for PostgreSQL cluster.

By default, databases are created with the LC_COLLATE=C and LC_CTYPE=C encoding settings. This allows PostgreSQL to run queries with string data types more efficiently, but may sometimes work counter-intuitively (for example, with Cyrillic). These settings are covered in more detail in the PostgreSQL documentation.

Alert

The LC_COLLATE and LC_CTYPE settings of a database cannot be changed after its creation.

You can configure character collation and sorting settings for columns when you create and edit
specific tables. Learn more in the PostgreSQL documentation.

Management console
CLI
API

To create a database:

  1. Go to the folder page and select Managed Service for PostgreSQL.

  2. Click on the name of the cluster you need.

  3. If the owner of the new database still doesn't exist, add the user.

  4. Select the Databases tab.

  5. Click Add.

  6. Enter the database name, select its owner, and configure the character set.

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 create a database in a cluster:

  1. See the description of the CLI's create database command:

    $ yc managed-postgresql database create --help
    
  2. Request a list of cluster users to select the owner of the new database:

    $ yc managed-postgresql user list
         --cluster-name <cluster name>
    

    If the required user is not in the list, create it.

  3. Run the create database command. If needed, specify the character collation and sorting settings (default settings are LC_COLLATE=C and LC_CTYPE=C):

    $ yc managed-postgresql database create <database name>
         --cluster-name <cluster name>
         --owner <username of the DB owner>
         --lc-collate ru_RU.UTF-8
         --lc-type ru_RU.UTF-8
    

    Managed Service for PostgreSQL runs the create database operation.

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

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

Deleting a database

Management console
CLI
API
  1. Go to the folder page and select Managed Service for PostgreSQL.
  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-postgresql database delete <database name>
     --cluster-name=<cluster name>

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

You can delete a database using the delete method.

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:
  • Getting a list of cluster databases
  • Creating a database
  • Deleting a database
Language
Careers
Privacy policy
Terms of use
© 2021 Yandex.Cloud LLC