Sign In Try Free

Explore Your Data with AI-Powered Chat2Query (beta)

TiDB Cloud is powered by AI. You can use Chat2Query (beta), an AI-powered SQL editor in theTiDB Cloud console, to maximize your data value.

In Chat2Query, you can either simply type--followed by your instructions to let AI generate SQL queries automatically or write SQL queries manually, and then run SQL queries against databases without a terminal. You can find the query results in tables intuitively and check the query logs easily.

Use cases

The recommended use cases of Chat2Query are as follows:

  • Use the AI capacity of Chat2Query to help you generate complex SQL queries instantly.
  • Test out the MySQL compatibility of TiDB quickly.
  • Explore TiDB SQL features easily.

Limitation

Access Chat2Query

  1. Go to theClusterspage of your project.

  2. Click your cluster name, and then clickChat2Queryin the left navigation pane.

Enable or disable AI to generate SQL queries

PingCAP takes the privacy and security of users' data as a top priority. The AI capacity of Chat2Query only needs to access database schemas to generate SQL queries, not your data itself. For more information, seeChat2Query Privacy FAQ.

When you access Chat2Query for the first time, you will be prompted with a dialog about whether to allow PingCAP and OpenAI to use your code snippets to research and improve the services.

  • To enable the AI to generate SQL queries, select the checkbox and clickSave and Get Started.
  • To disable the AI to generate SQL queries, close this dialog directly.

After the first-time access, you can still change the AI setting as follows:

  • To enable AI, clickEnable AI power for data explorationin the upper-right corner of Chat2Query.
  • To disable AI, clickin the lower-left corner of theTiDB Cloud console, clickAccount Settings, click thePrivacytab, and then disable theAI-powered Data Explorationoption.

Write and run SQL queries

In Chat2Query, you can write and run SQL queries using your own dataset.

  1. Write SQL queries.

    • If AI is enabled, simply type--followed by your instructions to let AI generate SQL queries automatically or write SQL queries manually.

      For a SQL query generated by AI, you can accept it by pressingTaband then further edit it if needed, or reject it by pressingEsc.

    • If AI is disabled, write SQL queries manually.

  2. Run SQL queries.

    • macOS
    • Windows/Linux

    For macOS:

    • If you have only one query in the editor, to run it, press⌘ + Enteror click Run.

    • If you have multiple queries in the editor, to run one or several of them sequentially, select the lines of the target queries with your cursor, and then press⌘ + Enteror clickRun.

    • To run all queries in the editor sequentially, press⇧ + ⌘ + Enter, or select the lines of all queries with your cursor and clickRun.

    For Windows or Linux:

    • If you have only one query in the editor, to run it, pressCtrl + Enteror click Run.

    • If you have multiple queries in the editor, to run one or several of them sequentially, select the lines of the target queries with your cursor, and then pressCtrl + Enteror clickRun.

    • To run all queries in the editor sequentially, pressShift + Ctrl + Enter, or select the lines of all queries with your cursor and clickRun.

After running the queries, you can see the query logs and results immediately at the bottom of the page.

Manage SQL files

In Chat2Query, you can save your SQL queries in different SQL files and manage SQL files as follows:

  • To add a SQL file, click+on theSQL Filestab.
  • To rename a SQL file, move your cursor on the filename, click...next to the filename, and then selectRename.
  • 删除一个SQL文件,在文件”按钮上移动光标name, click...next to the filename, and then select删除. Note that when there is only one SQL file on theSQL Filestab, you cannot delete it.

Generate an endpoint from a SQL file

For TiDB clusters, TiDB Cloud provides aData Service (beta)feature that enables you to access TiDB Cloud data via an HTTPS request using a custom API endpoint. In Chat2Query, you can generate an endpoint of Data Service (beta) from a SQL file by taking the following steps:

  1. 移动你的铜rsor on the filename, click...next to the filename, and then selectGenerate endpoint.
  2. In theGenerate endpointdialog box, select the Data App you want to generate the endpoint for and enter the endpoint name.
  3. ClickGenerate. The endpoint is generated and its details page is displayed.

For more information, seeManage an endpoint.

Manage Chat2Query settings

In Chat2Query, you can change the following settings:

  • The maximum number of rows in query results
  • Whether to show system database schemas on theSchemastab
  • Whether to enableChat2Query API

To change the settings, take the following steps:

  1. In the upper-right corner of Chat2Query, click...and selectSettings.
  2. Change the settings according to your need.
  3. ClickSave.
Download PDF Request docs changes Ask questions on Discord
Playground
New
One-stop & interactive experience of TiDB's capabilities WITHOUT registration.
Was this page helpful?
Products
TiDB
TiDB Dedicated
TiDB Serverless
Pricing
Get Demo
Get Started
©2023PingCAP. All Rights Reserved.