Managing databases in Sharded PostgreSQL
You can add and delete databases, and view their info.
Getting a list of cluster databases
- Navigate to the Yandex Managed Service for Sharded PostgreSQL service.
- Click the name of your cluster and select the Databases tab.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Database.List method, e.g., via the following cURL
request:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-spqr/v1/clusters/<cluster_ID>/databases' -
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the DatabaseService.List method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/spqr/v1/database_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.spqr.v1.DatabaseService.List -
Check the server response to make sure your request was successful.
Getting database info
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Database.Get method, e.g., via the following cURL
request:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-spqr/v1/clusters/<cluster_ID>/databases/<DB_name>' -
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the DatabaseService.Get method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/spqr/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.spqr.v1.DatabaseService.Get -
Check the server response to make sure your request was successful.
Creating a database
-
Navigate to the Yandex Managed Service for Sharded PostgreSQL service.
-
Click the name of your cluster and select the Databases tab.
-
Click Create database.
-
Specify database settings:
-
Name
The database name may contain Latin letters, numbers, underscores, and hyphens. The name may be up to 63 characters long. The following names are reserved:
postgres,template0, andtemplate1. You cannot create databases with these names. -
Deletion protection
The possible values are:
- Like the cluster
- Enabled
- DIsabled
-
-
Click Create.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Database.Create method, e.g., via the following cURL
request:curl \ --request POST \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-spqr/v1/clusters/<cluster_ID>/databases' \ --data '{ "databaseSpec": { "name": "<DB_name>", "deletionProtection": "<protect_database_from_deletion>" } }'Where
databaseSpecare the new database settings:-
name: Database name.The database name may contain Latin letters, numbers, underscores, and hyphens. The name may be up to 63 characters long. The following names are reserved:
postgres,template0, andtemplate1. You cannot create databases with these names. -
deletionProtection: Database deletion protection,trueorfalse.
-
-
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the DatabaseService.Create method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/spqr/v1/database_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "database_spec": { "name": "<DB_name>", "deletion_protection": "<protect_database_from_deletion>" } }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.spqr.v1.DatabaseService.CreateWhere
database_specare the new database settings:-
name: Database name.The database name may contain Latin letters, numbers, underscores, and hyphens. The name may be up to 63 characters long. The following names are reserved:
postgres,template0, andtemplate1. You cannot create databases with these names. -
deletion_protection: Database deletion protection,trueorfalse.
-
-
Check the server response to make sure your request was successful.
Deleting a database
To delete a database:
- Navigate to the Yandex Managed Service for Sharded PostgreSQL service.
- Click the name of your cluster and select the Databases tab.
- Find the database you need in the list, click
in its row, select Delete, then confirm the deletion.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Database.Delete method, e.g., via the following cURL
request:curl \ --request DELETE \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-spqr/v1/clusters/<cluster_ID>/databases/<DB_name>' -
Check the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it into an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume that the repository contents reside in the
~/cloudapi/directory. -
Call the DatabaseService.Delete method, e.g., via the following gRPCurl
request:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/spqr/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.spqr.v1.DatabaseService.Delete -
Check the server response to make sure your request was successful.