SQL Keywords and the Shape of a Statement
The first time you read a real query it can look like a wall of capital letters. It is far less random than it looks: a handful of reserved words mark where each part of the statement begins, and they always appear in the same order. Learn the order once and every query becomes readable.
The rule
Keywords are SQL's grammar; everything else is a name you chose.
A keyword is a word with a fixed meaning to the database: SELECT, FROM, WHERE, CREATE, TABLE, ORDER, BY. Everything else in a statement is an identifier (a table or column name you created) or a value (like 'Pune' or 42).
SELECT name, city -- keyword, then column names
FROM customers -- keyword, then a table name
WHERE city = 'Pune' -- keyword, then a condition
ORDER BY name; -- keywords, then a column; ; ends the statementA few rules follow from this:
- Keywords are case-insensitive.
select,SELECTandSelectall work. Writing them in capitals is a convention that makes your own names stand out. - A statement ends with a semicolon. Some tools let you skip it for a single statement, but it is required to separate several.
- Reserved words make poor names. A table called
orderclashes with the keywordORDER, which is one reason tables are often plural, likeorders. - Text values go in single quotes:
'Pune'. Double quotes, in standard SQL, are for identifiers.
Keywords also come in families by job. DDL (data definition) shapes tables: CREATE, ALTER, DROP, TRUNCATE. DML (data manipulation) works with rows: SELECT, INSERT, UPDATE, DELETE. DCL controls access: GRANT, REVOKE. TCL controls transactions: COMMIT, ROLLBACK.
The shortcut
The clauses of a query are always written in this order. Remember it as "Some Friendly Wizards Go Hunting Owls":
SELECT → FROM → WHERE → GROUP BY → HAVING → ORDER BY
You may skip clauses, but never reorder the ones you use.
Find the keywords
In
SELECT city FROM customers WHERE joined_on > '2025-01-01' ORDER BY city;the keywords are SELECT, FROM, WHERE, ORDER BY.
A common mistake is writing WHERE after ORDER BY. The mnemonic catches it at once: Wizards come before Owls.
Drills
Answer fast — trust the rule.
Which clause order is valid?
Is select name from customers; a valid statement?
Which of these is a DDL keyword?
SELECT * FROM order; fails with a syntax error. What is the most likely cause?
Remember
- Keywords are SQL's grammar; everything else is a name you chose.
- Clause order: Some Friendly Wizards Go Hunting Owls — SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY.
- Single quotes for text values; avoid reserved words as names.
