Every SQL statement belongs to one of five command groups. Knowing the group tells you what the statement touches and how it behaves in a transaction. Group Stands for Acts on Commands DDL Data Definition Language structure (tables, views, indexes) CREATE, ALTER, DROP, TRUNCATE, RENAME, COMMENT DQL Data Query Language reads rows SELECT (with FROM, WHERE, JOIN, GROUP BY, HAVING, ORDER BY) DML Data Manipulation Language changes rows INSERT, UPDATE, DELETE, MERGE / upsert DCL Data Control Language permissions GRANT, REVOKE (DENY in SQL Server) TCL Transaction Control Language units of work BEGIN, COMMIT, ROLLBACK, SAVEPOINT Some books fold SELECT into DML; separating it as DQL makes the read/write split clearer. DELETE vs TRUNCATE vs DROP DELETE (DML) TRUNCATE (DDL) DROP (DDL) Removes…
Key Takeaways
DDL defines structure, DQL reads, DML changes rows, DCL controls access, TCL groups work into transactions.
DELETE removes chosen rows; TRUNCATE empties a table fast; DROP removes the table itself.
Use BEGIN / COMMIT / ROLLBACK (and SAVEPOINT) so related changes succeed or fail together.
DDL auto-commits in Oracle and MySQL but is transactional in PostgreSQL, SQL Server and SQLite.