JOSEMARCEL FELICITY CHINAZA
5 TYPES OF
SQL
STATEMENTS
@TECHLADYNAZA
1. DDL (DATA DEFINITION LANGUAGE)
– SCHEMA DEFINITION
DDL statements define and modify database
structures.
📌 Example:
CREATE TABLE Employees (
ID INT PRIMARY KEY,
Name VARCHAR(50),
Position VARCHAR(50),
Salary DECIMAL(10,2)
);
Common DDL Commands:
CREATE – Defines new tables, databases, indexes, and
views.
ALTER – Modifies an existing table structure.
DROP – Deletes a table or database.
TRUNCATE – Removes all records from a table but
keeps its structure.
2. DML (DATA MANIPULATION
LANGUAGE) – DATA HANDLING
DML statements are used to interact with the data
stored in tables.
📌 Example:
INSERT INTO Employees (ID, Name, Position, Salary)
VALUES (1, 'Alice Johnson', 'Manager', 75000.00);
UPDATE Employees
SET Salary = 80000.00
WHERE ID = 1;
DELETE FROM Employees
WHERE ID = 1;
Common DML Commands:
SELECT – Retrieves data.
INSERT – Adds new records.
UPDATE – Modifies existing records.
DELETE – Removes records.
3. DCL (DATA CONTROL LANGUAGE) –
PERMISSION MANAGEMENT
DCL statements control user access
and privileges.
📌 Example:
GRANT SELECT, INSERT ON Employees
TO user1;
REVOKE INSERT ON Employees FROM
user1;
Common DCL Commands:
GRANT – Assigns privileges to users.
REVOKE – Removes privileges.
4. TCL (TRANSACTION CONTROL
LANGUAGE) – TRANSACTION
MANAGEMENT
TCL statements handle database transactions to
maintain integrity.
📌 Example:
START TRANSACTION;
UPDATE Employees
SET Salary = 85000.00
WHERE ID = 1;
SAVEPOINT BeforeUpdate;
ROLLBACK TO BeforeUpdate; -- Undo changes
COMMIT; -- Save changes
Common TCL Commands:
COMMIT – Saves a transaction.
ROLLBACK – Reverts changes.
SAVEPOINT – Sets a rollback point.
5. DQL (DATA QUERY LANGUAGE) –
DATA RETRIEVAL
DQL mainly includes SELECT, used to
fetch records.
📌 Example:
SELECT Name, Position FROM Employees
WHERE Salary > 70000
ORDER BY Name ASC;
Common DQL Command:
SELECT – Retrieves data based on
conditions.
THANK
YOU!
Dont forget to like,
comment, and share
@TECHLADYNAZA