Building with AI

Text-to-SQL

Quick explainer2 min readIntermediate

Text-to-SQL turns a question written in everyday language into a SQL query that a database can run, so people can ask for data without writing code.

In plain words

Databases answer questions written in SQL, a precise query language most people do not know. A text-to-SQL system reads a plain question plus a description of the database's tables and writes the matching query. It is hard because the model must handle databases it has never seen, messy values and outside knowledge. Benchmarks such as Spider and BIRD measure how often the generated queries are right.

A quick example

Imagine a shop manager typing "Which five products sold most last month?". The system looks at the tables for products and orders, writes a SQL query that groups and counts sales, runs it, and shows the list. A person should still check the query before trusting important numbers.

Where you'll meet it

  • Chat-style interfaces for business data.
  • Helping analysts draft queries faster.

Related

Sources

  1. PaperCan LLM Already Serve as A Database Interface? A BIg Bench for Large-Scale Database Grounded Text-to-SQLs, Li et al. (arXiv) · read 29 Sept 2026
  2. PaperSpider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-SQL Task, Yu et al. (arXiv) · read 29 Sept 2026

Checked by WhatIsAI against the sources above · 29 Sept 2026. Spotted an error? Report it.