Stay organized with collections Save and categorize content based on your preferences.
Preview — Gemini Code Assist
This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the Service Specific Terms. You can process personal data for this feature as outlined in the Cloud Data Processing Addendum, subject to the obligations and restrictions described in the agreement under which you access Google Cloud. Pre-GA features are available "as is" and might have limited support. For more information, see the launch stage descriptions.
This document describes how you can use Gemini, an AI-powered collaborator in Google Cloud, to help you do the following in Cloud SQL Studio:
Learn how and when Gemini for Google Cloud uses your data.
This document is intended for database administrators and data engineers who are familiar with SQL, data analysis, and Cloud SQL. If you're new to Cloud SQL, see Cloud SQL overview.
Note: Coding assistance is part of Gemini Code Assist and is available at no charge until it's included in Gemini Code Assist Standard edition. This change will be communicated at a later date. At that time, you will need to acquire a Gemini Code Assist Standard edition license to continue to use coding assistance in Cloud SQL Studio. Before you beginOptional: To follow along with the examples in this document, create a Singers
table using the following schema:
CREATE TABLE
Singers (
SingerId BIGINT PRIMARY KEY,
FirstName VARCHAR(1024),
LastName VARCHAR(1024),
SingerInfo BYTEA,
BirthDate TIMESTAMPTZ
);
After you create the Singers
table, click refreshRefresh to update your database schema.
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 to projects, folders, and organizations.
You might also be able to get the required permissions through custom roles or other predefined roles.
You also need the cloudaicompanion.companions.generateChat
permission to use explain SQL statements in the query editor and cloudaicompanion.companions.generateCode
to use help me code.
As an early-stage technology, Gemini for Google Cloud products can generate output that seems plausible but is factually incorrect. We recommend that you validate all output from Gemini for Google Cloud products before you use it. For more information, see Gemini for Google Cloud and responsible AI.
You can give Gemini natural language comments (or prompts) to generate queries that are based on your schema. For example, you can prompt Gemini to generate SQL in response to the following prompts:
If your schema changes, such as addition of a new table or column, then click refreshRefresh to update your schema before using Gemini.
Note: When you enter a prompt for Gemini in Cloud SQL, information about your database's schema is included with the prompt. This metadata can include table and column names, data types, and column descriptions. Your database data remains in Cloud SQL and isn't sent to Gemini.To generate SQL in Cloud SQL with Gemini assistance, follow these steps:
In the Google Cloud console, go to the Cloud SQL page.
Select an instance from the list.
In the navigation menu, click Cloud SQL Studio.
Sign in to Cloud SQL Studio using the name of your database, username, and password. The Explorer pane displays a list of objects in your database.
In the taskbar, click pen_sparkarrow_drop_downGemini to view Gemini features in Cloud SQL.
Ensure that Comment-to-query generation is enabled.
To query your database, click add New SQL editor tab.
To generate SQL, type a comment in the query editor starting with --
followed by a single-line comment, and then press Return or Enter.
For example, enter the following prompt:
-- add a row to table singers
Press Return or Enter. Gemini generates SQL that's similar to the following:
INSERT INTO Singers (SingerId, FirstName, LastName, BirthDate)
VALUES (1, 'Alex', 'M.', '1977-10-16');
To continue the example using the Singers
table, enter the following prompt:
-- show all singers born in the 70s
Gemini generates SQL that's similar to the following:
SELECT *
FROM Singers
WHERE Singers.BirthDate
BETWEEN '1970-01-01' AND '1979-12-31'
Note: Gemini might suggest different queries each time that you enter the same prompt.Review the SQL suggestion and take any of the following actions:
Caution: Because Data Manipulation Language (DML) and Data Definition Language (DDL) queries generated by Gemini can overwrite data, we recommend that you validate the generated queries before you run the queries.Tab
, then click Run.Control
+Right arrow
. (or Command
+Right arrow
on macOS), then click Run.Tab
, edit the SQL, and then click Run.Esc
or continue typing.To use the Help me code tool, follow these steps:
In the Google Cloud console, go to the Cloud SQL page.
Select an instance from the list.
In the navigation menu, click Cloud SQL Studio.
Sign in to Cloud SQL Studio using the name of your database, username, and password. The Explorer pane displays a list of objects in your database.
To query your database, click the add New tab.
Click pen_spark Help me code next to the query editor.
In the Help me code window, enter a prompt. For example, add a row to table singers
and click Generate.
Gemini generates SQL that's similar to the following:
INSERT INTO Singers (SingerId, FirstName, LastName, BirthDate)
VALUES (1, Alex, 'M.', '1977-10-16');
Note: Gemini might suggest different syntax each time that you enter the same prompt.Review the generated SQL and take any of the following actions:
Caution: Because Data Manipulation Language (DML) and Data Definition Language (DDL) queries generated by Gemini can overwrite data, we recommend that you validate the generated queries before you run the queries.You can use Gemini in Cloud SQL to explain SQL queries in natural language. This explanation can help you understand the syntax, underlying schema, and business context for complex or long queries.
In the Google Cloud console, go to the Cloud SQL page.
Select an instance from the list.
In the navigation menu, click Cloud SQL Studio.
Sign in to Cloud SQL Studio using the name of your database, username, and password. The Explorer pane displays a list of objects in your database.
To query your database, click the add New tab.
In the query editor, paste the query you want explained.
Highlight the query that you want Gemini to explain, and then click spark Explain this query.
The explanation for the SQL query appears in the Gemini Chat window.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-11 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-11 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4