SteelReed

Search

Search posts, questions…

SQL & Query TuningQuestion 1 / 37

Junior

What are DDL, DML, DCL and TCL? How do DELETE, TRUNCATE and DROP differ?

Short answer

SQL has groups: DDL (table structure), DML (data), DCL (permissions), TCL (transactions). DELETE removes row by row, TRUNCATE empties the data but keeps the table, DROP removes the whole table.

SQL statementDDL: structureCREATE, ALTER, DROP,TRUNCATEDML: dataSELECT, INSERT, UPDATE,DELETEDCL: permissionsGRANT, REVOKETCL: transactionsCOMMIT, ROLLBACK,SAVEPOINT

3 points to say:

  1. TRUNCATE is DDL and fast.
  2. DELETE has WHERE and fires triggers.
  3. Delete large volumes in batches.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.