How to Manage Logical Databases for Vultr Managed Databases for PostgreSQL

Updated on November 27, 2024

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.

  • Vultr Customer Portal
  • Vultr API
  • Vultr CLI
  1. Navigate to Products and select Databases.

  2. Click the target database instance.

    Select Managed Database

  3. Navigate to Users and Databases and click Add New Database.

    Users and Databases

  4. Enter the Database Name (For example, sample_company_db) and click Add Database.

    Enter a Database Name

  5. Click Destroy Database to delete the database.

    Database List

  1. 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}"
    
  2. Send a POST request to the Create Logical Database endpoint specifying the name 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.

  3. 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}"
    
  4. Send a DELETE request to the Delete Logical Database endpoint specifying the ID and the logical database name 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}"
    
  1. List all database instances and note the database ID. For instance, d6ac2a3c-92ea-43ef-8185-71a23e58ad8c.

    console
    $ vultr-cli database list --summarize
    
  2. 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
    
  3. 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.