Cloud SQL Studio 支援輕量查詢。如果回應超過 10 MB,可能會遭到截斷。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"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-03 (世界標準時間)。"],[],[],null,["# Manage your data using Cloud SQL Studio\n\n\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\n### Required 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\n### Authenticate 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\n### Explore 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\n### Create, 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 - 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**.\n7. 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.\n\n### Limitations\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"]]