4.
Structured Query Language
(SQL)
Databases Course
Introduction
• - SQL is the standard language for managing
relational databases
• - Used for data definition, manipulation, and
control
• - Widely supported across DBMS platforms
Data Definition Language (DDL)
• - Defines and manages database structures
• - Commands: CREATE, ALTER, DROP
• - Example: CREATE TABLE Students(ID INT,
Name VARCHAR(50))
Data Manipulation Language (DML)
• - Used to query and modify data
• - Commands: SELECT, INSERT, UPDATE, DELETE
• - Example: SELECT * FROM Students WHERE
Age > 20
Data Control Language (DCL)
• - Manages user access and permissions
• - Commands: GRANT, REVOKE
• - Example: GRANT SELECT ON Students TO
User1
Joins and Subqueries
• - Joins: combine rows from multiple tables
• - Types: INNER, LEFT, RIGHT, FULL
• - Subqueries: queries within queries
• - Example: SELECT Name FROM Students
WHERE ID IN (SELECT StudentID FROM
Grades)
Transactions
• - Ensure reliable execution of multiple
operations
• - Properties: ACID (Atomicity, Consistency,
Isolation, Durability)
• - Commands: BEGIN, COMMIT, ROLLBACK
Summary
• - SQL is essential for relational database
management
• - Includes DDL, DML, and DCL commands
• - Supports joins, subqueries, and transactions
• - Universal across DBMS platforms