Skip to main content

Chat2SQL

NineData offers the Chat2SQL feature, which allows for the rapid conversion of brief natural language expressions into SQL statements. This document will guide you on how to use this feature.

Feature Description

  • Natural Language Query: Utilizing advanced semantic parsing technology, it can understand your query intentions and translate them into the correct SQL query statements, thereby improving query efficiency and accuracy. You only need to input your query requests in natural language, without the need to be familiar with SQL language.
  • Multiple Operation Modes: Supports a variety of operations, including create, delete, update, and query.
  • Database Structure Automatic Recognition: It can automatically recognize the database structure and table names you want to query, without manual input, reducing the possibility of input errors and query time. You just need to select the target database in the data source.
  • Efficient Data Processing: Supports large-scale data processing and efficient queries, capable of handling large datasets containing millions of rows of data. At the same time, Chat2SQL also provides functionality, helping you quickly optimize SQL statements, thus more efficiently querying and processing data.

Usage Scenarios

  • Users without SQL programming experience: Chat2SQL can help users without SQL programming experience to query and analyze data. These users may be business personnel, marketing personnel, customer service representatives, etc., who need to query data to make business decisions but do not have professional skills to handle data.

  • Large data volume: When the amount of data to be processed is very large, manually writing SQL query statements becomes difficult and time-consuming, and slow SQL that may result is also threatening the performance of the server. Chat2SQL can help users quickly write complex query statements and optimize them as needed, avoiding the occurrence of slow SQL while quickly finding the required information.

  • Complex queries: For those who need to perform complex queries, Chat2SQL can provide more efficient and accurate query results. For example, when performing complex queries such as multi-table joins, nested queries, conditional aggregation, etc., Chat2SQL can help users quickly generate the correct query statements.

Prerequisites

  • The type of data source used must be one of the following: MySQL, PostgreSQL, Vastbase.
  • In the commercial versions (, ), please ensure that your monthly/yearly subscription is not expired, as it may result in the inability to use the Database DevOpsservice. You can quickly check the remaining quota and expiration date at the top right corner of the NineData console page.

    check_quota

Operation Steps

  1. Log in to the NineData Console.

  2. Click on in the left navigation bar.

  3. Depending on your previous operations on the SQL Console, the situation will be different:

    • If you have logged into a data source before and it has not been closed, you will automatically enter the page of that data source. In this case, click the + button to the right of the SQL Console tab, select the target test data source in the page, and click to open a new SQL Console.

    • If you have not logged into a data source before or the data source has been completely closed, click the dropdown under . A list of your added data sources will appear. Select the target data source and click to navigate to the SQL Console.

  4. In the SQL editing window, type the / key, and a text input window will be displayed. Enter the content you want to query inside, press the key or click the send icon on the right side of the text box to send. AI will analyze your needs and generate the corresponding SQL statements.

Add Comments (Enhanced AI)

You can add comments to target tables and fields. When using the Chat2SQL feature, the system generates more accurate SQL statements based on the contextual information provided in these comments. Comment content can include the meaning of fields, business logic, foreign key constraint conditions for field values, and more, helping the AI better understand user intent.

Note: All configurations made in this step are solely for enhancing AI accuracy and will not make any changes to the actual database.

  1. Log in to the NineData Console.

  2. In the left navigation bar, click > .

  3. Depending on your previous actions in the SQL Console, the situation may vary:

    • If you have logged into a data source before and it has not been closed, you will automatically enter the page of that data source. In this case, click the + button to the right of the SQL Console tab, select the target test data source in the page, and click to open a new SQL Console.
    • If you have not logged into a data source before or the data source has been completely closed, click the dropdown under . A list of your added data sources will appear. Select the target data source and click to navigate to the SQL Console.
  4. In the left navigation tree, right-click the target database name > . In the popup , click the column next to the target table and select .

    tip

    You can also directly right-click the name of a target table or column in the left navigation tree > .

  5. In the window, you can add . Click the column next to the target column name and select to add and configure for that column.

  6. Click to save your changes.