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 roleroles/owner
: the Owner basic IAM roleroles/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 Clusters page.
In the Resources name column, 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 database dialog window.
In the Log in to your database window, make the following selections:
- Select the
postgres
database. - Select a database authentication method and enter a username and password.
- Select the
Click Authenticate. The Explorer pane displays a list of the objects in the
postgres
database.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.
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:
In the Google Cloud console, go to the Clusters page.
To open the Overview page of a cluster, click the cluster name in the Resources name column.
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:
In the Google Cloud console, go to the Clusters page.
To open the Overview page of a cluster, click the cluster name in the Resources name column.
Click Databases from the left-side menu. The Databases page 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 database dialog window opens.Click Open in Studio.
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.