Database management

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

Getting a list of databases in a cluster

  1. Go to the folder page and click 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 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 flag.

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

$ yc managed-postgresql 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.

Creating a database

The number of databases in a cluster is unlimited.

  1. Go to the folder page and click Managed Service for PostgreSQL.
  2. Click on the name of the cluster you need.
  3. If a new database should be owned by a non-existing user, create a user.
  4. Select the Databases tab.
  5. Click Add.
  6. Enter the database name and select its owner.

If you don't have the Yandex.Cloud command line interface yet, install 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 flag.

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 a user.

  3. Run the create database command:

    $ yc managed-postgresql database create <DB name>
         --cluster-name <cluster name>
         --owner <username of the DB owner>
    

    Managed Service for PostgreSQL runs the create database operation.

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.

Removing a database

  1. Go to the folder page and click Managed Service for PostgreSQL.
  2. Click on the name of the cluster you need and select the Databases tab.
  3. Click image in the line of the necessary DB and select Delete.

If you don't have the Yandex.Cloud command line interface yet, install 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 flag.

To remove a database, run the command:

$ yc managed-postgresql database delete <DB 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.