Create and manage a database

This page describes how to create and manage a database in AlloyDB for PostgreSQL.

Before you begin

The Google Cloud project you use must be enabled to access AlloyDB.

You must have one of the following IAM roles in the Google Cloud project that you're using:

  • roles/alloydb.admin: the AlloyDB Admin predefined IAM role
  • roles/owner: the Owner basic IAM role
  • roles/editor: the Editor basic IAM role

If you don't have any of these roles, contact your Organization Administrator to request access.

Create a database

Before you can create a database, you must create a cluster and its primary instance.

To create a database, complete the following steps:

  1. In the Google Cloud console, go to the Clusters page.

    Go to Clusters

  2. In the Resources name column, click the name of your cluster.

  3. In the navigation pane, click Databases.

  4. Click Create a database. A dialog window opens that suggests a query to use in AlloyDB Studio.

  5. Copy the query and click Open in Studio. The AlloyDB Studio page opens with an additional Log in to your database dialog window.

  6. In the Log in to your database window, make the following selections:

  7. Click Authenticate. The Explorer pane displays a list of the objects in the postgres database.

  8. Select the Untitled Query tab and paste the following query that you copied:

    CREATE DATABASE DATABASE_NAME;
    

    Replace DATABASE_NAME with the name of the database.

  9. Click Run.

    If the Statement executed successfully message displays in the Results pane, then you know that you created your database.

List a database

To list all databases on a cluster, complete the following steps:

  1. In the Google Cloud console, go to the Clusters page.

    Go to Clusters

  2. To open the Overview page of a cluster, click the cluster name in the Resources name column.

  3. Click Databases from the left-side menu. The Databases page lists the database names along with their collation type and character set.

Delete a database

To delete a database in a cluster, complete the following steps:

  1. In the Google Cloud console, go to the Clusters page.

    Go to Clusters

  2. To open the Overview page of a cluster, click the cluster name in the Resources name column.

  3. Click Databases from the left-side menu. The Databases page lists the database names along with their collation type and character set.

  4. Choose a database to delete, click the three-dot menu in that row, and select Drop. A Drop a database dialog window opens.

  5. Click Open in Studio.

  6. In the open Untitled Query tab, Click Run.

    If the Statement executed successfully message displays in the Results pane, then you know that you deleted the database.