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:
-
In the Google Cloud console, go to the Clusterspage.
-
In the Resources namecolumn, click the name of your cluster.
-
In the navigation pane, click Databases.
-
Click Create a database. A dialog window opens that suggests a query to use in AlloyDB Studio.
-
Copy the query and click Open in Studio. The AlloyDB Studio page opens with an additional Log in to your databasedialog window.
-
In the Log in to your databasewindow, make the following selections:
- Select the
postgresdatabase. - Select a database authentication method and enter a username and password.
- Select the
-
Click Authenticate. The Explorerpane displays a list of the objects in the
postgresdatabase. -
Select the Untitled Querytab and paste the following query that you copied:
CREATE DATABASE DATABASE_NAME ;Replace DATABASE_NAME with the name of the database.
-
Click Run.
If the Statement executed successfullymessage displays in the Resultspane, then you know that you created your database.
List a database
To list all databases on a cluster, complete the following steps:
-
In the Google Cloud console, go to the Clusterspage.
-
To open the Overviewpage of a cluster, click the cluster name in the Resources namecolumn.
-
Click Databasesfrom the left-side menu. The Databasespage 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:
-
In the Google Cloud console, go to the Clusterspage.
-
To open the Overviewpage of a cluster, click the cluster name in the Resources namecolumn.
-
Click Databasesfrom the left-side menu. The Databasespage lists the database names along with their collation type and character set.
-
Choose a database to delete, click the three-dot menu in that row, and select Drop. A Drop a databasedialog window opens.
-
Click Open in Studio.
-
In the open Untitled Querytab, Click Run.
If the Statement executed successfullymessage displays in the Resultspane, then you know that you deleted the database.

