---
Title: "What Is Text-to-SQL? How AI Queries Databases"
Url: "https://computer.io/glossary/text-to-sql"
Topic: "AI foundations"
Description: "Text-to-SQL is AI that turns plain-language questions into SQL queries, so anyone can ask data questions. How it works, accuracy and limits."
---

# What is text-to-SQL?

Text-to-SQL is the use of AI to convert a plain-language question, such as "How many urgent tickets did we close last week?", into a SQL query that runs against a database, so people can get answers from data without writing code.

## How it works

1. The model receives the question and the database schema.
2. It writes a SQL query.
3. The query runs.
4. Results are summarized or charted.

## Accuracy tips

| Tip | Why |
| --- | --- |
| Clear table and column names | Fewer mistakes |
| Business definitions | "Active customer" means one thing |
| Read-only access | Safety |
| Show the SQL | Users can verify |

## FAQ

### Is text-to-SQL accurate?

Good for common questions; complex schemas and definitions need care.

### Is text-to-SQL safe?

Use read-only access and respect row-level permissions.

### Who uses text-to-SQL?

Analysts, managers and support leaders who need quick answers.

## Related terms

- [Large language model (LLM)](https://computer.io/glossary/large-language-model)
- [Knowledge graph](https://computer.io/glossary/knowledge-graph)
- [Tool calling (function calling)](https://computer.io/glossary/tool-calling)

## How Computer helps

- [Enterprise search and answers](https://devrev.ai/enterprise-search-and-answers)

## Further reading

- [What is enterprise search](https://devrev.ai/blog/what-is-enterprise-search)
