What are DDL, DML, DCL, TCL?
These are classes of SQL commands that group database operations by purpose:
1. DDL (Data Definition Language)
Used to create and change the database's structure. Example commands:
CREATE TABLE, create a tableALTER TABLE, change a table (add a column, change a data type)DROP TABLE, delete a table
The gist: manages structure, not data.
2. DML (Data Manipulation Language)
Used to add, change, delete, and retrieve data. Example commands:
SELECT, retrieve dataINSERT, insert a new recordUPDATE, change an existing recordDELETE, delete a record
The gist: works with the actual data inside tables.
3. DCL (Data Control Language)
Used to manage user rights and security. Example commands:
GRANT, give a user rightsREVOKE, take rights away
The gist: controls who's allowed to do what in the database.
4. TCL (Transaction Control Language)
Used to manage the logic of running groups of operations (transactions). Example commands:
COMMIT, confirm changesROLLBACK, undo changesSAVEPOINT, create a save point inside a transaction
The gist: ensures data integrity when several operations run at once.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.