Chapter 7: Introduction to Structured Query Language (SQL)
1. Introduction to SQL
SQL stands for Structured Query Language. It is the standard language used to create, modify, retrieve, and
manipulate data in relational databases.
2. SQL Commands Classification
DDL (Data Definition Language): CREATE, ALTER, DROP
DML (Data Manipulation Language): INSERT, UPDATE, DELETE
DCL (Data Control Language): GRANT, REVOKE
TCL (Transaction Control Language): COMMIT, ROLLBACK, SAVEPOINT
DQL (Data Query Language): SELECT
3. Creating Database and Tables (DDL)
Commands like CREATE DATABASE and CREATE TABLE define structure. Data types include INT,
VARCHAR, DATE. Constraints: PRIMARY KEY, FOREIGN KEY, NOT NULL, DEFAULT, CHECK.
4. Altering and Dropping Tables
ALTER TABLE adds or removes columns. DROP TABLE deletes a table permanently.
5. Inserting and Updating Data (DML)
INSERT INTO adds new data. UPDATE modifies existing data. DELETE removes rows.
6. Retrieving Data (SELECT Statement)
SELECT retrieves data. WHERE filters data. Operators include AND, OR, NOT, BETWEEN, LIKE, IN, IS
NULL.
7. Sorting and Filtering Results
ORDER BY sorts results. DISTINCT shows unique values.
Chapter 7: Introduction to Structured Query Language (SQL)
8. Aggregate Functions
Functions like COUNT, SUM, AVG, MIN, MAX summarize data.
9. Grouping Data
GROUP BY groups rows. HAVING filters grouped results.
10. Joins in SQL
INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN combine rows from multiple tables.
11. Aliases and Recursive Joins
AS keyword renames columns or tables. Recursive joins relate a table to itself.
12. Transaction Control
COMMIT saves changes. ROLLBACK undoes changes. SAVEPOINT creates a restore point.
Tips for UG Students
Practice SQL regularly. Use tools like SQL Fiddle, MySQL Workbench. Start with simple queries and build
up.