DML
DML
Definition
DML (Data Manipulation Language) is the family of SQL statements that change the data stored inside existing tables, without changing the table's structure. The three core DML verbs are INSERT, UPDATE, and DELETE.
How It Works
sqlINSERT INTO employees (id, name, department, salary) VALUES (9, 'Farah', 'Engineering', 81000); UPDATE employees SET salary = 83000 WHERE id = 9; DELETE FROM employees WHERE id = 9;
Unlike DDL, DML changes are transactional on every mainstream engine — they can be wrapped in BEGIN ... COMMIT and undone with ROLLBACK as long as the transaction hasn't been committed yet. This is one of the clearest practical distinctions between DDL and DML.
The WHERE clause is what makes UPDATE and DELETE targeted instead of total — omitting it is one of the most damaging mistakes possible in SQL: UPDATE employees SET salary = 0; with no WHERE sets every row's salary to zero, and DELETE FROM employees; with no WHERE deletes every row in the table.
Edge Cases and Pitfalls
- Running
UPDATE/DELETEwithout aWHEREclause is one of the single most common and most damaging real-world SQL mistakes — always double-check theWHEREclause (or run the equivalentSELECTfirst to preview which rows would be affected) before executing. INSERTinto a table with aNOT NULLcolumn that has no default value will fail if that column is omitted from theINSERT— the failure is a feature, not a bug (it prevents silently-incomplete rows).DELETEremoves rows one at a time (logged individually) and can be rolled back mid-transaction;TRUNCATE TABLE(a DDL-adjacent statement in most dialects) empties a table much faster but typically cannot be selectively filtered and, on many engines, cannot be rolled back the same way.
Key Takeaways
- DML = INSERT / UPDATE / DELETE — changes data, not structure.
- DML is transactional everywhere; DDL usually is not (see DDL) — this is the clearest practical dividing line between the two.
- Never run UPDATE or DELETE without checking the WHERE clause first — the difference between "some rows" and "every row" is exactly one missing clause.