Skip to main content

Generative AI

Initiating the Query Generation

Begin by clicking on the “Generate SQL” button located at the top right corner of your coding interface.

Name

Providing the Description

Input a detailed description of your data requirement into ChatGPT. An example could be, "I need a query that shows the customers, their full names, how much they paid, and their city of residence in 2004."

Name

Proceed by selecting 'Generate'.

Generating the SQL Query

ChatGPT will interpret your request and create a SQL query suitable for you. For the given example, ChatGPT's output might be:

SELECT 
c.customerName,
CONCAT(c.contactFirstName, ' ', c.contactLastName) AS fullName,
p.amount,
c.city
FROM customers c
JOIN payments p ON c.customerNumber = p.customerNumber
WHERE YEAR(p.paymentDate) = 2004;

Review and Modify

After receiving the query from ChatGPT, examine it to confirm it matches your database's structure and fulfills your data needs. Adjust as required and ensure to test it in a secure environment.

Testing the Query

With the assurance of a safe environment, let's check the effectiveness of our generated SQL code. Here are the results:

Name

Success Verification

We can confirm that the query has executed correctly.

note
  • The AI integration only accesses your database's structure, maintaining the confidentiality of your data.
  • The ChatGPT feature operates based on your subscription key to ChatGPT. Make sure you have an active subscription. You can link your OpenAI key via Profile -> OpenAI in your settings.
Name

Ensure that your database is thoroughly commented. The more comprehensive and detailed the comments are, the more accurate and effective the AI's results will be.