Cloud SQL Studio 支持轻量级查询。超过 10MB 的响应可能会被截断。如果返回部分结果,Cloud SQL Studio 会进行指示。
您只能对正在运行的 Cloud SQL 实例运行查询。
Cloud SQL Studio 不支持外部服务器。
处理时间超过五分钟的请求会被取消。不支持使用 SET SESSION MAX_EXECUTION_TIME 设置更高的查询超时时间。
对于 Cloud SQL for MySQL 5.6 和 5.7,长时间运行的 DDL 语句超时可能会导致出现无法安全回滚的孤立文件或表。对大型表执行 ALTER TABLE 这类查询时应小心谨慎。
SQL 脚本执行完成后,Cloud SQL Studio 不会使数据库连接保持打开状态。同样,编辑器标签页不会共享公共会话,每次执行都会启动新会话。
当您混合运行 DML、DQL 和 DDL 语句时,系统仅显示 DQL 查询的结果。
关闭浏览器或浏览器标签页不会停止 Cloud SQL Studio 中的查询执行。查询将运行,直到完成或超时。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-09。"],[],[],null,["\u003cbr /\u003e\n\nMySQL \\| [PostgreSQL](/sql/docs/postgres/manage-data-using-studio \"View this page for the PostgreSQL database engine\") \\| [SQL Server](/sql/docs/sqlserver/manage-data-using-studio \"View this page for the SQL Server database engine\")\n\n\u003cbr /\u003e\n\nThis page describes how to explore and manage your Cloud SQL data using\nCloud SQL Studio in the Google Cloud console.\n\nCloud SQL Studio lets authorized users interact directly with the SQL database\nand run SQL queries from the Google Cloud console to access and manipulate data.\nYou can perform a range of actions that\nyou would perform on a SQL command line client,\nsuch as creating tables and indexes, modifying tables, or setting up views.\n\nCloud SQL Studio includes an **Explorer** pane that integrates with a query\neditor and a SQL query results table. You can run DDL, DML, and DQL statements\nfrom this one interface. For example, instead of configuring a third-party\ndatabase query tool, you can create a table and query your data using the query\neditor in Cloud SQL Studio.\n\nYou can use the **Explorer** pane to view and interact with your database objects.\nYou create, alter, and delete the database objects, such as the following:\n\n- Tables\n- Columns\n- Indexes and keys\n- Functions\n\nYou can also use the **Explorer** pane to seed `SELECT` queries for tables.\n| **Note:** System-level views in the `INFORMATION_SCHEMA` schema is read-only.\n\nIf you're new to Cloud SQL, see\n[Cloud SQL overview](/sql/docs/mysql/introduction).\n\nRequired roles and permissions\n\n\nTo get the permissions that\nyou need to complete the tasks in this document,\n\nask your administrator to grant you the\n\n\n[Cloud SQL Studio User](/iam/docs/roles-permissions/cloudsql#cloudsql.studioUser) (`roles/cloudsql.studioUser`)\nIAM role on the project.\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nYou might also be able to get\nthe required permissions through [custom\nroles](/iam/docs/creating-custom-roles) or other [predefined\nroles](/iam/docs/roles-overview#predefined).\n\nTo use Cloud SQL Studio, you must have the following permissions:\n\n- `cloudsql.databases.list`\n- `cloudsql.instances.executeSql`\n- `cloudsql.instances.get`\n- `cloudsql.instances.login` (only required if you're using IAM database authentication)\n- `cloudsql.users.list`\n\nAdditionally, ensure that you have database-level permissions for the database\nthat you're using for authentication, and the password for the privileged\ndatabase user that you're using.\n\nAuthenticate to Cloud SQL Studio\n\nBefore you can access a database in Cloud SQL Studio,\nyou must first select a database authentication method. To sign in to your\ndatabase using Cloud SQL Studio, you can use one of the following types of authentication:\n\n- [IAM database authentication](/sql/docs/mysql/iam-authentication#iam-db-auth). Using\n this type of authentication lets you sign in to your database and\n Cloud SQL Studio without having to manage an extra password.\n You can also take advantage of [IAM group authentication](/sql/docs/mysql/iam-authentication#iam-group-auth)\n and manage the database access and privileges for multiple users in your\n organization at the same time.\n\n- [Built-in database authentication](/sql/docs/mysql/built-in-authentication).\n You connect to the database in Cloud SQL Studio by using your MySQL\n user account and credentials.\n\nExplore your data\n\nTo access the **Explorer** pane, follow these steps:\n\n1. In the Google Cloud console, go to the **Cloud SQL Instances** page.\n\n [Go to Cloud SQL Instances](https://console.cloud.google.com/sql)\n2. Select an instance from the list.\n3. In the navigation menu, click **Cloud SQL Studio**.\n4. 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.\n\nCreate, modify, and query your data\n\nUsing the SQL editor, you can run a combination of DDL, DML, and DQL statements.\nYou can compose a query yourself, or you can populate the query editor with a\ntemplate using the explorer.\n\nTo structure, modify, or query your data, follow these steps:\n\n1. In the Google Cloud console, go to the **Cloud SQL Instances** page.\n\n [Go to Cloud SQL Instances](https://console.cloud.google.com/sql)\n2. Select an instance from the list.\n3. In the navigation menu, click **Cloud SQL Studio**.\n4. Sign in to Cloud SQL Studio using the name of your database, username, and password.\n5. Compose a query using one of the following methods:\n - To compose your own query, follow these steps:\n 1. Open a new tab by clicking add.\n 2. When the query editor appears, write your query.\n - To compose a query starting with a template, follow these steps:\n 1. In the **Explorer** pane, next to a database object or collection, click more_vert **View actions**. One or more available actions appear.\n 2. Click an action. The query editor populates with a template.\n 3. Replace any placeholders in the template.\n6. Run your queries using either of the following approaches:\n\n - To execute all the statements in the query editor, click **Run**.\n - To run specific statements, select one or multiple statements, and click **Run selected**.\n - The results of your queries appear in the **Results** tab. If multiple result\n sets are available, select a result from the **All results** drop-down list.\n\nLimitations\n\n- Cloud SQL Studio supports lightweight queries. Responses over 10MB might be truncated. Cloud SQL Studio indicates when partial results are returned.\n- You can only run queries for Cloud SQL instances that are running.\n- Cloud SQL Studio doesn't support external servers.\n- Requests taking longer than five minutes are canceled. Setting a higher query timeout using `SET SESSION MAX_EXECUTION_TIME` isn't supported. 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.\n- 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.\n- When you run a mix of DML, DQL, and DDL statements, only results from the DQL queries will be displayed.\n- 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.\n\n\u003c!-- --\u003e\n\n- 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.\n- [Cloud SQL for MySQL client commands](https://dev.mysql.com/doc/refman/8.0/en/mysql-commands.html) aren't supported and can't be executed in Cloud SQL Studio.\n- The `root` user is not supported in Cloud SQL Studio.\n- Cloud SQL Studio always requires a database even if Cloud SQL for MySQL doesn't require a database to connect.\n- Users with empty passwords are not supported in Cloud SQL Studio.\n- `USE database` is stateful only for the active query execution and doesn't function the same as in the [gcloud CLI](/sdk/gcloud).\n- The database user must have the permission to connect from the localhost.\n- When running multiple queries and one of them fails, the first encountered\n error is returned. Some of the statements in the batch prior to the error\n might have executed successfully. You can wrap multiple queries in a\n `transaction` statement to prevent this issue:\n\n START TRANSACTION;\n \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eYOUR_SQL_STATEMENTS\u003c/span\u003e\u003c/var\u003e\n COMMIT;\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eYOUR_SQL_STATEMENTS\u003c/var\u003e: the statements you want to run as part of this query"]]