SQL · Queries that survive scale
What is SQL and what is it used for?
Short answer
SQL is the declarative language for defining, querying, and modifying data in relational databases. You describe the result you want, and the optimizer chooses how to execute it.
Relational databases store data in tables with typed columns and relationships between them. SQL is the standard interface: DDL defines structure, DML changes rows, and SELECT reads them.
SELECT id, email, created_at
FROM users
WHERE created_at >= '2026-01-01'
ORDER BY created_at DESC
LIMIT 20;What the language covers
- DDL: CREATE, ALTER, and DROP tables, indexes, views, and constraints
- DML: INSERT, UPDATE, DELETE, and upsert or merge variants
- DQL: SELECT with joins, aggregation, subqueries, and window functions
- Transaction and access control: BEGIN, COMMIT, ROLLBACK, GRANT, and REVOKE
Because SQL is declarative, two queries returning the same rows can have very different cost. The planner uses statistics and index metadata to choose a plan, which is why query plans matter as data grows.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1What is the difference between DDL and DML?
- 2Why is SQL called declarative?
- 3How does a database decide how to execute a query?
- 4Which parts of SQL are not portable across databases?
Say it in the interview
SQL is a declarative language for defining and querying relational data. I describe the rows and columns I need, and the optimizer chooses how to read them using indexes, statistics, and join strategies. It covers schema changes, data changes, queries, and transaction control. I keep engine differences in mind because syntax and behavior vary across databases.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live SQL mock interview and get scored feedback on depth, clarity and confidence.