SQL is a declarative language: you describe what data you want, and the database engine decides how to fetch it. It is not a general-purpose language like Python—it specializes in tables, rows, and set operations.
Core characteristics
- Set-oriented — operations work on whole tables or filtered subsets, not one row at a time in application code
- Standardized — ANSI SQL defines common syntax; vendors add extensions
- Four statement classes — DDL (schema), DML (data), DCL (permissions), TCL (transactions)
- Ubiquitous — Postgres, MySQL, SQLite, SQL Server, Oracle, and cloud warehouses all speak SQL variants
Statement categories
-- DDL: define structure
CREATE TABLE products (id INTEGER PRIMARY KEY, name TEXT);
-- DML: manipulate rows
INSERT INTO products (name) VALUES ('Notebook');
SELECT * FROM products;
UPDATE products SET name = 'Journal' WHERE id = 1;
DELETE FROM products WHERE id = 1;Practice: Copy SQL into sqlite3 practice.db, DB Fiddle, or a local Postgres session. Compare row counts and column names with the lesson.
SQL vs application code
Application layers (Django ORM, PHP PDO, Python pandas) often generate SQL. Understanding the underlying statements helps you debug slow queries, write migrations, and pass interviews.
Important interview questions and answers
- Q: Is SQL a programming language?
A: It is a database language—declarative for queries and data changes, with limited procedural extensions in some engines. - Q: DDL vs DML?
A: DDL changes structure (CREATE, ALTER, DROP); DML changes or reads rows (SELECT, INSERT, UPDATE, DELETE).
Self-check
- Which statement reads data without modifying it?
- Name one DDL and one DML keyword.
Tip: Keep a cheat sheet of DDL vs DML vs TCL—interviews love the classification.
Interview prep
- DDL vs DML?
DDL changes schema; DML reads or changes row data.
- Is SQL procedural?
Core SQL is declarative—some engines add procedural extensions.