🧾 SQL References & Functions
Estimated reading: 3 minutes 106 views

πŸ“š SQL Keywords List – DDL, DML, DQL, and TCL Explained

🧲 Introduction – Why SQL Keywords Matter

SQL keywords are reserved words that form the foundation of all SQL queries. These keywords define structure, perform operations, and control logicβ€”from creating tables to filtering, joining, and modifying data.

Whether you’re writing a basic SELECT or a complex stored procedure, mastering SQL keywords is essential for readable, maintainable, and powerful queries.

🎯 In this guide, you’ll learn:

  • Essential SQL keywords categorized by purpose
  • Syntax examples and use cases
  • Platform compatibility and keyword rules
  • Reserved word handling and naming best practices

πŸ”‘ 1. Core SQL Keywords (DQL – Data Query Language)

KeywordDescriptionExample
SELECTRetrieves dataSELECT * FROM employees;
FROMSpecifies tableFROM users
WHEREFilters resultsWHERE age > 25
ORDER BYSorts result setORDER BY salary DESC
GROUP BYAggregates dataGROUP BY department
HAVINGFilters grouped resultsHAVING COUNT(*) > 2
DISTINCTRemoves duplicatesSELECT DISTINCT city FROM customers;
LIMITLimits number of rows (MySQL, PostgreSQL)LIMIT 10
TOPLimits rows in SQL ServerSELECT TOP 5 * FROM orders;

🧱 2. Data Definition Language (DDL) Keywords

KeywordDescriptionExample
CREATECreates objectsCREATE TABLE users (...);
DROPDeletes objectsDROP TABLE orders;
ALTERModifies structureALTER TABLE products ADD category_id;
RENAMERenames objectsALTER TABLE old_name RENAME TO new_name;
TRUNCATEDeletes all rows (faster than DELETE)TRUNCATE TABLE logs;

πŸ”§ 3. Data Manipulation Language (DML) Keywords

KeywordDescriptionExample
INSERTAdds new rowsINSERT INTO users VALUES (...);
UPDATEModifies existing rowsUPDATE users SET name = 'John';
DELETERemoves rowsDELETE FROM users WHERE id = 3;
VALUESSpecifies values in INSERTVALUES ('Alice', 28)
SETUsed in UPDATE or variable assignmentSET age = 30

πŸ” 4. Data Control Language (DCL) Keywords

KeywordDescriptionExample
GRANTAssigns privilegesGRANT SELECT ON employees TO analyst;
REVOKERemoves privilegesREVOKE INSERT ON orders FROM intern;

πŸ’Ύ 5. Transaction Control Language (TCL) Keywords

KeywordDescriptionExample
BEGINStarts a transactionBEGIN;
COMMITSaves transactionCOMMIT;
ROLLBACKUndoes transactionROLLBACK;
SAVEPOINTPartial rollback pointSAVEPOINT before_update;

πŸ” 6. SQL Operators and Conditional Keywords

KeywordDescriptionExample
AND, OR, NOTLogical operatorsWHERE age > 25 AND city = 'NY'
INMatch from a listWHERE id IN (1, 2, 3)
BETWEENMatch rangeWHERE salary BETWEEN 30000 AND 60000
LIKEPattern matchingWHERE name LIKE 'J%'
IS NULLChecks for nullsWHERE phone IS NULL
CASEConditional logicCASE WHEN score > 90 THEN 'A' ... END

🧠 7. Advanced and Analytical SQL Keywords

KeywordDescriptionExample
JOINCombines rows from multiple tablesINNER JOIN orders ON users.id = ...
UNIONMerges two queriesSELECT ... UNION SELECT ...
EXISTSChecks for existenceWHERE EXISTS (SELECT 1 FROM ...)
WITHDefines CTE (Common Table Expression)WITH cte AS (SELECT ...)
WINDOW, OVERUsed in window functionsROW_NUMBER() OVER (PARTITION BY ...)

πŸ›‘οΈ 8. Reserved Words and Naming Rules

  • Avoid using SQL keywords as column or table names (e.g., SELECT, USER)
  • If unavoidable, use quotes or brackets:
    • PostgreSQL: "user"
    • MySQL: `user`
    • SQL Server: [user]

πŸ’‘ Use snake_case or camelCase for custom names to improve readability.


πŸ“Œ Summary – Recap & Learning Path

SQL keywords form the vocabulary of SQLβ€”without them, there’s no query language. Knowing the purpose and proper use of each keyword ensures that your queries are both correct and optimized.

πŸ” Key Takeaways:

  • SQL keywords are case-insensitive but usually written in UPPERCASE
  • Reserved words should not be used as identifiers
  • Learn keywords by function: DDL, DML, DCL, TCL, DQL

βš™οΈ Real-World Relevance:
Used in all forms of development: database schema design, ETL workflows, data reporting, application queries, and stored procedures.


❓ FAQ – SQL Keywords

❓ Are SQL keywords case-sensitive?

βœ… No. SELECT, select, and SeLeCt are treated the same. But convention prefers UPPERCASE for readability.

❓ Can I use a keyword as a column name?

βœ… Yes, but you must escape it using double quotes, backticks, or brackets depending on your RDBMS.

❓ How can I view all reserved keywords?


Share Now :
Share

πŸ“š SQL Keywords

Or Copy Link

CONTENTS
Scroll to Top