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, and CLI.
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.
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
.
$ 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 the name
of the logical database and the database ID.
$ 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.
$ 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 database name
to delete the logical database.
$ curl "https://api.vultr.com/v2/databases/database_id/dbs/logical_database_name" \
-X DELETE \
-H "Authorization: Bearer ${VULTR_API_KEY}"
List all database instances and note the database ID. For instance, d6ac2a3c-92ea-43ef-8185-71a23e58ad8c
.
$ vultr-cli database list --summarize
Create a logical database by specifying the database name (For example, sample_company_db
) and the database ID.
$ vultr-cli database db create database_id --name database_name
List all logical databases by specifying a database ID.
$ vultr-cli database db list database_id
Run vultr-cli database db --help
to view all options.