SQL Keywords Reference
A quick reference guide for essential SQL Reserved Keywords, categorized by functional language subset.
1. Data Query Language (DQL)
Used to fetch data from database tables.
| Keyword | Description |
|---|---|
SELECT |
Specifies columns to retrieve from a table. |
FROM |
Specifies the source table or view. |
WHERE |
Filters records based on search conditions. |
GROUP BY |
Groups rows with identical data into summary rows. |
HAVING |
Filters groups created by GROUP BY. |
ORDER BY |
Sorts the result set ascending (ASC) or descending (DESC). |
DISTINCT |
Removes duplicate rows from the query output. |
LIMIT / TOP |
Constrains the maximum number of rows returned. |
2. Data Manipulation Language (DML)
Used to add, modify, or remove data rows.
| Keyword | Description |
|---|---|
INSERT INTO |
Adds new rows of data into a table. |
UPDATE |
Modifies existing values inside a table. |
DELETE |
Removes specific rows from a table based on conditions. |
MERGE / UPSERT |
Performs INSERT, UPDATE, or DELETE in a single atomic operation. |
Advertisement
3. Data Definition Language (DDL)
Used to define, alter, and manage database schema structures.
| Keyword | Description |
|---|---|
CREATE |
Creates database objects (tables, views, indexes, procedures). |
ALTER |
Modifies the structure of an existing database object. |
DROP |
Deletes a database object along with all its data and structure. |
TRUNCATE |
Efficiently removes all rows from a table without logging individual row deletes. |
4. Join Keywords
Used to combine rows from two or more tables based on related columns.
| Keyword | Description |
|---|---|
JOIN / INNER JOIN |
Returns matching rows present in both tables. |
LEFT JOIN |
Returns all records from the left table, and matched records from the right table. |
RIGHT JOIN |
Returns all records from the right table, and matched records from the left table. |
FULL JOIN |
Returns records when there is a match in either left or right table. |
CROSS JOIN |
Produces the Cartesian product of rows from both tables. |
ON |
Specifies the condition for joining two tables. |
USING |
Concise shorthand join condition when columns in both tables share the exact same name. |
Advertisement
5. Logical & Comparison Operators
Used within conditional filtering statements (WHERE, HAVING).
| Keyword | Description |
|---|---|
AND |
Combines multiple conditions; evaluates to true if all conditions are true. |
OR |
Combines multiple conditions; evaluates to true if any condition is true. |
NOT |
Inverts the truth value of a condition. |
IN |
Checks if a value matches any value within a defined list or subquery. |
BETWEEN |
Checks if a value falls inclusively within a specified range. |
**LIKE / ILIKE** |
Matches string patterns using wildcards (% for strings, _ for single characters). |
**IS NULL / IS NOT NULL** |
Evaluates whether a value is empty/absent. |
EXISTS |
Tests whether a subquery returns at least one row. |
Advertisement
6. Schema & Structural Constraints
Used to enforce data integrity during table definition.
| Keyword | Description |
|---|---|
PRIMARY KEY |
Uniquely identifies each row in a table (implies NOT NULL + UNIQUE). |
FOREIGN KEY |
Enforces a link between columns in two tables (referential integrity). |
REFERENCES |
Identifies the parent table and column target for a FOREIGN KEY. |
UNIQUE |
Ensures all values stored within a column are distinct. |
NOT NULL |
Prevents empty/null values from being inserted into a column. |
CHECK |
Validates that column values satisfy a custom expression condition. |
DEFAULT |
Defines a default value when no explicit value is provided during insertion. |
Advertisement
7. Control Flow & Set Operators
Used for conditional logic branching and set operations.
| Keyword | Description |
|---|---|
**CASE / WHEN / THEN / ELSE** |
Implements standard IF-THEN-ELSE conditional evaluation logic within queries. |
COALESCE |
Evaluates arguments in order and returns the first non-null value. |
UNION |
Combines results from multiple queries into a single dataset, removing duplicates. |
UNION ALL |
Combines results from multiple queries into a single dataset, keeping duplicates. |
INTERSECT |
Returns only rows that are output by both queries. |
**EXCEPT / MINUS** |
Returns rows from the first query that do not exist in the second query. |
WITH |
Defines a Common Table Expression (CTE) or temporary named result set. |
Advertisement
8. Data Control Language (DCL) & Transaction Control (TCL)
Used for administrative security and transaction safety.
| Keyword | Description |
|---|---|
GRANT |
Gives user accounts privileges to access or modify database objects. |
REVOKE |
Removes previously assigned access privileges from users or roles. |
COMMIT |
Permanently saves all modified transaction operations to disk. |
ROLLBACK |
Cancels all pending changes in the current transaction, restoring prior state. |
SAVEPOINT |
Sets an intermediate undo checkpoint within a multi-step transaction block. |