This page explains how to explore and manage your AlloyDB for PostgreSQL data
using AlloyDB Studio in the Google Cloud console.

AlloyDB Studio includes an **Explorer** pane that
integrates with a query editor and a SQL query results table.
You can run DDL, DML, and DQL statements from this single interface. For
example, instead of configuring a third-party database query tool, you can
create a table or query your data using this query editor.

If you're new to AlloyDB for PostgreSQL, see
[AlloyDB overview](https://docs.cloud.google.com/alloydb/docs/overview).

You can use the **Explorer** pane in AlloyDB Studio to view and interact
with your database objects. You can create, alter, and delete the following
database objects:

- Schemas
- Tables
- Columns
- Indexes and keys
- Triggers
- Views
- Functions
- Procedures
- Sequences
- Types
- Extensions

## Required roles and permissions


> [!CAUTION]
> **Caution:** Users with broad database access could experience data loss when using Gemini. We recommend that you use an account with fewer database privileges when using Gemini.

<br />

To use AlloyDB Studio, you need the following permissions:

- `alloydb.clusters.get`
- `alloydb.databases.list`
- `alloydb.instances.executeSql`
- `alloydb.instances.list`
- `alloydb.users.list`

You can get these permissions through the
[`roles/alloydb.admin`](https://docs.cloud.google.com/alloydb/docs/reference/iam-roles-permissions#roles)
role, or using a combination of
[`roles/alloydb.viewer`](https://docs.cloud.google.com/alloydb/docs/reference/iam-roles-permissions#roles)
and
[`roles/alloydb.databaseUser`](https://docs.cloud.google.com/alloydb/docs/reference/iam-roles-permissions#roles)
roles. If you don't have these roles, contact your Organization Administrator to
request access. You might also be able to get the required permissions through
[custom roles](https://docs.cloud.google.com/iam/docs/creating-custom-roles) or other
[predefined roles](https://docs.cloud.google.com/iam/docs/understanding-roles).

Additionally, ensure that
you have [database-level permissions](https://docs.cloud.google.com/alloydb/docs/database-users/about)
for the database that you use for authentication.

## Authenticate to AlloyDB Studio

Before you can access a database in AlloyDB Studio, you must first select a
database authentication method. To sign in to your database using
AlloyDB Studio, you can use one of the following types of authentication:

- [IAM database authentication](https://docs.cloud.google.com/alloydb/docs/database-users/iam-authentication): use IAM
  authentication to manage the database access and privileges for users in your
  organization. To use this, set up
  [IAM authentication](https://docs.cloud.google.com/alloydb/docs/database-users/manage-iam-auth)
  on the instance.

- [Built-in database authentication](https://docs.cloud.google.com/alloydb/docs/database-users/built-in-authentication): connect to the database in
  AlloyDB Studio by using your PostgreSQL user account and credentials. For
  more information, see
  [Manage PostgreSQL users with built-in authentication](https://docs.cloud.google.com/alloydb/docs/database-users/manage-roles).

## Explore your data

To access the **Explorer** pane, follow these steps:

1. In the Google Cloud console, open the **AlloyDB** page.

   [Go to AlloyDB](https://console.cloud.google.com/alloydb)
2. Select a cluster from the list.

3. In the navigation menu, click **AlloyDB Studio**.

4. Select a [database authentication method](https://docs.cloud.google.com/alloydb/docs/manage-data-using-studio#authentication).

5. Click **Authenticate** . The **Explorer** pane displays a list of the objects
   in your database.

## Create, modify, and query your data

You can use the query editor to run SQL statements. Statements must be separated
by a semicolon. Compose a query yourself, or populate the query editor with a
template.

Statement execution is based on the order in which you enter them in the query
editor.

To create, query, or modify your data, follow these steps:

1. In the Google Cloud console, open the **AlloyDB** page.

   [Go to AlloyDB](https://console.cloud.google.com/alloydb)
2. Select a cluster from the list.

3. In the navigation menu, click **AlloyDB Studio**.

4. Sign in to AlloyDB Studio using the name of your database, username,
   and password.

5. Compose a query using one of the following methods:

   - To compose your own query, follow these steps:

     1. Click **New SQL editor tab** or **New tab** to open a new tab.
     2. When the query editor appears, write your query.
   - To compose a query that starts with a template, follow these steps:

     1. In the **Explorer** pane, next to a database object, click more_vert **View actions**. One or more available actions appear.
     2. Click an action. The query editor populates with a template.
     3. Replace any placeholders in the template.
6. Click **Run** . This executes all the queries in the query editor. The
   results of your query appear in the **Results** table.

   You can also select and execute one or multiple queries at the same time.
   To do this, select a query or multiple queries and click **Run selected**.

## Limitations

- AlloyDB Studio supports lightweight queries. Responses over 10MB might be truncated. AlloyDB Studio indicates when it returns partial results.
- Long-running queries or index creations on large tables that exceed five minutes on the instance are timed-out and cancelled.
- AlloyDB Studio doesn't keep a database connection open after execution of a SQL script is complete. Similarly, the **Editor** tabs don't share a common session and every execution starts a new connection using a separate session.
- When you run multiple query statements at the same time, and one of the queries results in an error, then the whole query is cancelled.

## What's next

- Learn more about how [Gemini can help you write SQL or analyze your data](https://docs.cloud.google.com/alloydb/docs/write-sql-gemini).