How it works
SQL is declarative: you describe the result you want, such as all paid orders from last week with each customer's name, and the database works out how to fetch it. SELECT reads data, INSERT, UPDATE and DELETE change it, JOIN combines tables, GROUP BY summarises, and CREATE TABLE defines the structure.
It grew out of IBM research in the 1970s, based on Edgar Codd's relational model, and has been an ANSI and ISO standard since the 1980s. Every database adds its own dialect (T-SQL in SQL Server, PL/pgSQL in PostgreSQL), so the basics transfer everywhere while advanced features differ. Analysts and product managers use it as much as developers, and data warehouses such as BigQuery and Snowflake speak it too.
Building SQL by pasting user input into a string invites SQL injection, a long-standing and serious attack, so apps pass values separately as parameters, or use an ORM or query builder that does it for them.
SQL pros and cons
Pros
- One language that works across nearly every relational database
- Very expressive for filtering, joining and summarising data
- Stable for decades, so the skill lasts a career
- Readable enough for analysts and non-developers to learn
Cons
- Dialects differ between databases beyond the basics
- Complex queries get hard to read and to speed up
- Careless string building leads to SQL injection
When to use SQL
Pick it when
- Working with any relational database
- Reports, dashboards and one-off questions about data
- Analytics in warehouses such as BigQuery, Snowflake or ClickHouse
Skip it when
- The data lives in a document store such as Firestore, which has its own query API
SQL pricing
Free
The language is free to use. Many databases that speak it are open source; commercial ones such as Oracle Database and SQL Server charge licence fees.
Approximate, checked September 2026.What the other tools cost
Related terms
More in Programming languages
Data and scripting