Generate SQL from natural language

Turn natural-language requests into SQL for the DB contexts selected in AI Chat.

How to use

Describe the goal and conditions, then review the SQL cards.

1

Open AI Chat

Open the AI panel and choose a new or existing conversation.

2

Choose a model and context

Select the Provider Key, model, Connections, and Schemas for this request.

3

Send a natural-language request

Describe the data, period, conditions, and output columns you need.

4

Review explanation and SQL

Check the route, WHERE clause, and expected impact on each inline SQL card.

Using contexts

Context is not a hint priority; it is the strict database scope available to this request.

  • Select Schemas from multiple Connections to compare or combine relationships.
  • The AI cannot discover or query unselected Connections with Tools.
  • Even with multiple contexts, every executable SQL statement needs one unambiguous target route.
  • Change the Provider Key and contexts before sending the next message.

DB checks

Within the selected scope, the AI can progressively inspect what it needs to write SQL.

  • Find Connections and Table and View lists.
  • Inspect columns, keys, indexes, relationships, and constraints.
  • Inspect an estimated plan on a supported DBMS when needed.
  • After approval, run a read-only SELECT of at most 10 rows to check actual values.

Review results

Read the explanation and SQL together and verify target and impact before execution.

  • Review filters, sorting, and aggregation for SELECT and WHERE clauses and scope for DML and DDL.
  • Run or copy from the SQL card, or open an editable regular SQL Editor copy.
  • Verify the Connection, Database, and Schema route.
  • DML and DDL follow the target Connection's data-change and schema-change auto-apply policies.

Prompt examples

Include the goal, period, filters, and output columns for more accurate SQL.

GoalExample prompt
AggregationShow monthly order totals for the last six months and the percentage change from the previous month.
Relationship queryShow the ID, name, and last order date for active members who have not ordered in the last 30 days.
Data changeWrite an UPDATE that deactivates expired temporary coupons, and explain the expected impact and WHERE clause.
Tip

For data-changing SQL, check the target Connection's data-change policy and review the WHERE clause and impact.