How to Manage Logical Databases for Vultr Managed Databases for PostgreSQL
-
by Blog Admin
- 6
How to Manage Logical Databases for Vultr Managed Databases for PostgreSQL
A guide for creating and managing logical databases within your Vultr Managed PostgreSQL database service.
Logical databases provide a structured collection of data creating a workspace for tables that in turn consist of columns and rows. A single database can store dozens or even hundreds of tables. For instance, in an e-commerce website, a database can store products
, categories
, sales
, and payments
tables.
Follow this guide to manage logical databases for Vultr Managed Databases for PostgreSQL using the Vultr Customer Portal, API, CLI, or Terraform.
Vultr Customer Portal
- Navigate to Products and select Databases.
- Click the target database instance.
- Navigate to Users and Databases and click Add New Database.
- Enter the Database Name (For example,
sample_company_db
) and click Add Database. - Click Destroy Database to delete the database.
Vultr API
- List all the database instances by sending a
GET
request to the List Managed Databases endpoint and note the database ID. For example,43b4c774-5dff-4ac0-a01f-78a23c2205b5
.console$ curl "https://api.vultr.com/v2/databases" \ -X GET \ -H "Authorization: Bearer ${VULTR_API_KEY}"
- Send a
POST
request to the Create Logical Database endpoint specifying thename
of the logical database and the database ID.console$ curl "https://api.vultr.com/v2/databases/database_id/dbs" \ -X POST \ -H "Authorization: Bearer ${VULTR_API_KEY}" \ -H "Content-Type: application/json" \ --data '{ "name" : "sample_company_db" }'
Visit the Create Logical Database endpoint to view additional attributes to add to your request.
- Send a
GET
request to the List Logical Databases endpoint specifying the database ID to list the logical databases.console$ curl "https://api.vultr.com/v2/databases/database_id/dbs" \ -X GET \ -H "Authorization: Bearer ${VULTR_API_KEY}"
- Send a
DELETE
request to the Delete Logical Database endpoint specifying the ID and the logical databasename
to delete the logical database.console$ curl "https://api.vultr.com/v2/databases/database_id/dbs/logical_database_name" \ -X DELETE \ -H "Authorization: Bearer ${VULTR_API_KEY}"
Vultr CLI
- List all database instances and note the database ID. For instance,
d6ac2a3c-92ea-43ef-8185-71a23e58ad8c
.console$ vultr-cli database list --summarize
- Create a logical database by specifying the database name (For example,
sample_company_db
) and the database ID.console$ vultr-cli database db create database_id --name database_name
- List all logical databases by specifying a database ID.
console
$ vultr-cli database db list database_id
Run
vultr-cli database db --help
to view all options.
Terraform
- Ensure the Vultr Terraform provider is configured.
- Create a logical database with Terraform.
terraform
terraform { required_providers { vultr = { source = "vultr/vultr" version = "~> 2.26" } } } provider "vultr" {} # Existing database assumed variable "database_id" { type = string } resource "vultr_database_db" "app" { database_id = var.database_id name = "sample_company_db" }
- To delete the logical database, remove the resource block or run:
console
$ terraform destroy -target vultr_database_db.app
How to Manage Logical Databases for Vultr Managed Databases for PostgreSQL A guide for creating and managing logical databases within your Vultr Managed PostgreSQL database service. Logical databases provide a structured collection of data creating a workspace for tables that in turn consist of columns and rows. A single database…
How to Manage Logical Databases for Vultr Managed Databases for PostgreSQL A guide for creating and managing logical databases within your Vultr Managed PostgreSQL database service. Logical databases provide a structured collection of data creating a workspace for tables that in turn consist of columns and rows. A single database…