Manage your data using Cloud SQL Studio

This page describes how to explore and manage your Cloud SQL data using Cloud SQL Studio in the Google Cloud console.

Cloud SQL Studio lets authorized users interact directly with the SQL database and run SQL queries from the Google Cloud console to access and manipulate data. You can perform a range of actions that you would perform on a SQL command line client, such as creating tables and indexes, modifying tables, or setting up views.

Cloud SQL 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 one interface. For example, instead of configuring a third-party database query tool, you can create a table and query your data using the query editor in Cloud SQL Studio.

You can use the Explorer pane to view and interact with your database objects. You create, alter, and delete the database objects, such as the following:

  • Tables
  • Columns
  • Indexes and keys
  • Functions

You can also use the Explorer pane to seed SELECT queries for tables.

If you're new to Cloud SQL, see Cloud SQL overview.

Required roles and permissions

To get the permissions that you need to complete the tasks in this document, ask your administrator to grant you the Cloud SQL Admin (roles/cloudsql.admin) IAM role on the project. For more information about granting roles, see Manage access.

You might also be able to get the required permissions through custom roles or other predefined roles.

To use Cloud SQL Studio, you must have the following permissions:

  • cloudsql.instances.get
  • cloudsql.users.list
  • cloudsql.databases.list
  • cloudsql.instances.executeSql

Additionally, ensure that you have database-level permissions for the database that you're using for authentication, and the password for the privileged database user that you'll be using. IAM authentication is not supported in Cloud SQL Studio.

Explore your data

To access the Explorer pane, follow these steps:

  1. In the Google Cloud console, go to the Cloud SQL Instances page.

    Go to Cloud SQL Instances

  2. Select an instance from the list.
  3. In the navigation menu, click Cloud SQL Studio.
  4. Sign in to Cloud SQL Studio using the name of your database, username, and password. The Explorer pane displays a list of the objects in your database.

Create, modify, and query your data

Using the SQL editor, you can run a combination of DDL, DML, and DQL statements. You can compose a query yourself, or you can populate the query editor with a template using the explorer.

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

  1. In the Google Cloud console, go to the Cloud SQL Instances page.

    Go to Cloud SQL Instances

  2. Select an instance from the list.
  3. In the navigation menu, click Cloud SQL Studio.
  4. Sign in to Cloud SQL 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. Open a new tab by clicking .
      2. When the query editor appears, write your query.
    • To compose a query starting with a template, follow these steps:
      1. In the Explorer pane, next to a database object or collection, 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. Run your queries using either of the following approaches:
    • To execute all the statements in the query editor, click Run.
    • To run specific statements, select one or multiple statements, and click Run selected.
  7. The results of your queries appear in the Results tab. If multiple result sets are available, select a result from the All results drop-down list.

Limitations

  • Cloud SQL Studio supports lightweight queries. Responses over 8MB might be truncated. Cloud SQL Studio indicates when partial results are returned.
  • You can only run queries for Cloud SQL instances that are running.
  • Cloud SQL Studio doesn't support external servers.
  • Requests taking longer than one minute are canceled. For Cloud SQL for MySQL 5.6 and 5.7, long running DDL statements timing out may cause orphaned files or tables that can't be safely rolled back. Be cautious with queries like ALTER TABLE on large tables.
  • Cloud SQL Studio doesn't keep a database connection open after execution of a SQL script is completed. Similarly, editor tabs don't share a common session and every execution starts a new session.
  • When you run a mix of DML, DQL, and DDL statements, only results from the DQL queries will be displayed.
  • Closing your browser or browser tab doesn't stop the query execution in Cloud SQL Studio. The query will run until it completes or times out.
  • Cloud SQL Studio doesn't support running SELECT queries on BLOB data. If the SQL script produces a BLOB column in the output, then the SQL script fails with an error.
  • Cloud SQL for MySQL client commands aren't supported and can't be executed in Cloud SQL Studio.
  • The root user is not supported in Cloud SQL Studio.
  • Cloud SQL Studio always requires a database even if Cloud SQL for MySQL doesn't require a database to connect.
  • Users with empty passwords are not supported in Cloud SQL Studio.
  • USE database is stateful only for the active query execution and doesn't function the same as in the gcloud CLI.
  • The database user must have the permission to connect from the localhost.
  • When running multiple queries and one of them fails, the first encountered error is returned. Some of the statements in the batch prior to the error might have executed successfully. You can wrap multiple queries in a transaction statement to prevent this issue:

    START TRANSACTION;
        YOUR_SQL_STATEMENTS
    COMMIT;
    

    Replace the following:

    • YOUR_SQL_STATEMENTS: the statements you want to run as part of this query