Introduction to SQL
Emna
July 26, 2025
1 What is SQL?
SQL (Structured Query Language) is a standard language used to interact with relational
databases. It allows you to create, read, update, and delete data (often referred to as CRUD
operations).
2 Basic SQL Commands
2.1 Creating a Table
CREATE TABLE Users (
ID INT PRIMARY KEY ,
Name VARCHAR (50) ,
Age INT
);
2.2 Inserting Data
INSERT INTO Users ( ID , Name , Age )
VALUES (1 , ’ Alice ’ , 25) ;
2.3 Reading Data
SELECT * FROM Users ;
SELECT Name FROM Users WHERE Age > 20;
2.4 Updating Data
UPDATE Users
SET Age = 26
WHERE ID = 1;
1
2.5 Deleting Data
DELETE FROM Users
WHERE ID = 1;
3 Common Clauses
• WHERE - Filters records
• ORDER BY - Sorts results
• GROUP BY - Groups rows
• HAVING - Filters groups
• JOIN - Combines rows from two or more tables
4 Example: JOIN
SELECT Orders . OrderID , Customers . Name
FROM Orders
JOIN Customers ON Orders . CustomerID = Customers . ID ;
5 Conclusion
SQL is essential for working with relational databases. Mastering SQL empowers you to
manage and analyze data effectively across a wide range of applications.