What are the 5 Basic SQL Commands? (DDL, DML, DCL, TCL, DQL)
Estimated study time: 23 minutes. Every SQL command falls into one of these five categories.
Every command you write in SQL belongs to one of five categories, based on what it actually does to the database. Knowing these categories makes it much easier to understand why SQL is organized the way it is.
1. DDL — Data Definition Language
Defines or changes the structure of database objects like tables and schemas.
CREATE TABLE students (id INT, name VARCHAR(50)); ALTER TABLE students ADD email VARCHAR(100); DROP TABLE students;
2. DML — Data Manipulation Language
Used to insert, update, or delete the actual data stored inside tables.
INSERT INTO students VALUES (1, 'Aman'); UPDATE students SET name = 'Aman Gupta' WHERE id = 1; DELETE FROM students WHERE id = 1;
3. DCL — Data Control Language
Controls access and permissions on database objects.
GRANT SELECT ON students TO analyst_user; REVOKE SELECT ON students FROM analyst_user;
4. TCL — Transaction Control Language
Manages transactions, ensuring multiple statements succeed or fail together.
BEGIN TRANSACTION; UPDATE accounts SET balance = balance - 500 WHERE id = 1; COMMIT;
5. DQL — Data Query Language
Retrieves data without changing it — this is simply the SELECT statement.
SELECT name, email FROM students WHERE id = 1;
Why This Grouping Matters
Recognizing which category a command belongs to helps you reason about permissions, rollback behavior, and impact — a DDL statement like DROP TABLE auto-commits in most databases, while DML changes can usually be rolled back until committed.