Skip to content
  • SQL Sublanguages: DDL, DML, DQL, DCL, TCL · SQL

SQL Sublanguages: DDL, DML, DQL, DCL, TCL

LearnViaNotes @learnvianotes· 2 min read

SQL commands are grouped by what they act on — the structure, the data, permissions, or transactions. A classic first interview question.

GroupStands forCommandsActs on
DDLData Definition LanguageCREATE, ALTER, DROP, TRUNCATE, RENAMESchema objects (tables, indexes, views)
DMLData Manipulation LanguageINSERT, UPDATE, DELETE, MERGERows inside tables
DQLData Query LanguageSELECTReading rows (often counted as part of DML)
DCLData Control LanguageGRANT, REVOKEPermissions of users and roles
TCLTransaction Control LanguageCOMMIT, ROLLBACK, SAVEPOINT, BEGINGrouping DML into atomic units

One of each

SQL
-- DDL: define structure
CREATE TABLE notes (id INTEGER PRIMARY KEY, body TEXT NOT NULL);

-- TCL + DML: change data inside a transaction
BEGIN;
INSERT INTO notes (body) VALUES ('learn SQL'), ('practice joins');
UPDATE notes SET body = 'practice window functions' WHERE id = 2;
COMMIT;

-- DQL: read it back
SELECT id, body FROM notes ORDER BY id;
Output
id | body
---+--------------------------
1  | learn SQL
2  | practice window functions
PostgreSQL / MySQL / SQL Server
-- DCL: permissions (server databases only; SQLite has no users)
GRANT SELECT, INSERT ON notes TO analyst;
REVOKE INSERT ON notes FROM analyst;

Why the grouping matters

Is TRUNCATE DDL or DML?

Is SELECT part of DML?

Free for students and teachers

Write notes like this one

Cards for every idea, quizzes and flashcards, read aloud — on the web and your phone.

Something wrong with this note? Open it to report