Introduction
Structured Query Language (SQL) is the standard language for talking to a relational database — a database that stores data in tables (rows and columns). Whenever you need to create a table, insert data, fetch the rows you want, update a value, or delete records, you write an SQL statement and the DBMS (Database Management System, e.g. MySQL, PostgreSQL, Oracle, SQL Server) carries it out.
For BCS, Bank, and IT-officer exams, SQL is one of the highest-yield topics in Database Management Systems. Questions are usually direct and factual: "Which command is DDL?", "What does GROUP BY do?", "Difference between DELETE and TRUNCATE?", "What is a PRIMARY KEY?", "Output of this JOIN?". If you master the command categories, the clause execution order, keys, joins, and aggregate functions, you can answer almost every SQL question quickly and correctly.
Learning objectives
After studying this lesson you will be able to:
- Define SQL and explain its role in a relational DBMS.
- Classify every SQL command into DDL, DML, DCL, TCL, and DQL.
- Write and read
SELECTqueries withWHERE,ORDER BY,GROUP BY,HAVING, andLIMIT. - Understand and predict the output of the six JOIN types.
- Use aggregate functions (
COUNT, SUM, AVG, MIN, MAX) correctly. - Distinguish
PRIMARY KEY,FOREIGN KEY,UNIQUE,NOT NULL,CHECK,DEFAULTconstraints. - Explain the differences between
DELETE,TRUNCATE, andDROP, and betweenWHEREandHAVING. - Handle
NULLcorrectly and avoid the classic exam traps.