SQL (Structured Query Language) is the language used to talk to a relational database — to create tables, insert data, and ask questions of that data ("give me every order over ₹5,000 placed last month").
What SQL Actually Does
Every relational database — MySQL, PostgreSQL, SQL Server, Oracle, SQLite — understands SQL. You use it to:
- Define structure — create databases, tables, and relationships (DDL)
- Insert / modify / remove data (DML)
- Query data — filter, sort, join, aggregate (DQL)
- Control access — who can read or write what (DCL)
- Manage transactions — commit or roll back a set of changes (TCL)
A Quick Example
Sample table employees:
| id | name | department | salary |
|---|---|---|---|
| 1 | Aman | Engineering | 65000 |
| 2 | Riya | Marketing | 52000 |
| 3 | Karan | Engineering | 71000 |
SELECT name, salary
FROM employees
WHERE department = 'Engineering'
ORDER BY salary DESC;
Output:
| name | salary |
|---|---|
| Karan | 71000 |
| Aman | 65000 |
That one statement reads like an English sentence — which is exactly why SQL has survived, largely unchanged in spirit, since 1974.
The Five Categories of SQL Commands
| Category | Stands For | Example Commands |
|---|---|---|
| DDL | Data Definition Language | CREATE, ALTER, DROP, TRUNCATE |
| DML | Data Manipulation Language | INSERT, UPDATE, DELETE |
| DQL | Data Query Language | SELECT |
| DCL | Data Control Language | GRANT, REVOKE |
| TCL | Transaction Control Language | COMMIT, ROLLBACK, SAVEPOINT |
SQL Is Not a Full Programming Language
SQL has no built-in concept of loops or general-purpose logic the way Python or Java does (procedural extensions like PL/pgSQL or T-SQL add that on top). It's a declarative language — you describe what result you want, not the step-by-step logic to get there. The database engine decides how to fetch it.
Where You'll Actually Use SQL
- Data Analytics — pulling and aggregating data for dashboards and reports
- Data Science — extracting and shaping data before modelling
- Backend / Full Stack Development — every app with a database talks to it in SQL under the hood
- Interviews — SQL rounds are standard for analyst, data science, and backend roles
Common Mistakes
- Thinking SQL and a database (like MySQL) are the same thing — SQL is the language; MySQL/PostgreSQL/etc. are the engines that implement it
- Assuming all databases run identical SQL — the core is standardized (ANSI SQL), but each vendor adds its own extensions and quirks
Interview Relevance
Q: "What's the difference between SQL and MySQL?" is a very common opener. Answer: SQL is the standard language for relational databases; MySQL is one specific database management system that implements SQL (with its own extensions).
Practice Question
Without running anything — which SQL command category (DDL/DML/DQL/DCL/TCL) does each of these belong to: CREATE TABLE, UPDATE, SELECT, GRANT, ROLLBACK?