What is DML?
Learn what DML is and how INSERT, UPDATE and DELETE change the data inside your tables.
In the DDL chapter you built empty tables. Now it's time to fill them and keep them up to date. A new player is signed (add a row), Dhoni scores more runs (change a value), a player is released (remove a row). All of these are DML jobs.
Definition
DML (Data Manipulation Language) is the group of SQL commands that add, change and remove the rows of data stored inside tables, without changing the tables' structure. Its three commands are INSERT, UPDATE and DELETE.
- Rows of data — DML works on the contents (Virat Kohli, 750 runs), not the columns or data types.
- Without changing structure — after any DML statement the table has exactly the same columns as before.
- INSERT / UPDATE / DELETE — one command for each kind of change.
The families of SQL commands
| Family | Full form | Works on | Commands |
|---|---|---|---|
| DQL | Data Query Language | Reading data | SELECT |
| DDL | Data Definition Language | Structure | CREATE, ALTER, DROP |
| DML | Data Manipulation Language | Data (rows) | INSERT, UPDATE, DELETE |
Note: Some books put
SELECTinside DML too (since it "manipulates" data by reading it). This course keeps it separate as DQL, which is also very common.
The three DML commands
| Command | What it does | IPL example |
|---|---|---|
INSERT | Adds new rows | Shubman Gill joins the database |
UPDATE | Changes existing data (values in rows that already exist) | Dhoni's runs go from 350 → 400 |
DELETE | Removes rows | Bumrah's row is removed |
Example — the table we will modify
sql
SELECT * FROM players;| id | name | team | country | runs |
|---|---|---|---|---|
| 1 | Virat Kohli | RCB | India | 750 |
| 2 | Rohit Sharma | MI | India | 500 |
| 3 | Jos Buttler | RR | England | 850 |
| 4 | MS Dhoni | CSK | India | 350 |
| 5 | David Warner | DC | Australia | 700 |
| 6 | Jasprit Bumrah | MI | India | 20 |
Every lesson in this chapter starts from this table, changes it, and then shows the table after the change.
"Rows affected" — how DML reports back
Unlike SELECT, DML statements don't return a result grid. SQL Server shows a message instead:
python
(1 row affected)Always read that number! If you expected to update 1 player and SQL Server says (6 rows affected), something is wrong (usually a missing WHERE).
DDL vs DML at a glance
| DDL | DML | |
|---|---|---|
| Changes | The structure (columns, types) | The data (rows, values) |
| Commands | CREATE, ALTER, DROP | INSERT, UPDATE, DELETE |
| Example | Add a jersey_no column | Set Kohli's jersey_no to 18 |
| Undo? | Usually permanent | Can be undone inside a transaction (ROLLBACK) |
Common mistakes
- ❌ Calling
DELETEa DDL command. ✅ It removes rows → DML. - ❌ Using
ALTERto change a player's runs. ✅ALTERchanges structure; useUPDATEfor values. - ❌ Ignoring the "rows affected" message. ✅ Check it every time.
Interview tip
Q: Name the DML commands and say what each does.
A: INSERT adds new rows, UPDATE modifies values in existing rows, and DELETE removes rows. (Some definitions also include SELECT and MERGE.) They change data, not table structure.
Key points to remember
- DML = Data Manipulation Language: commands that add, change and remove ROWS of data without changing table structure.
- INSERT adds new rows, UPDATE changes existing values, DELETE removes rows.
- DDL changes structure (CREATE/ALTER/DROP); DML changes data (INSERT/UPDATE/DELETE); DQL reads data (SELECT).
- DML statements return a message like '(1 row affected)' instead of a result grid.
- Always check the rows-affected count — it is your first sign that a WHERE was wrong or missing.
- DML changes can be undone with ROLLBACK if run inside a transaction.
Try it yourself
All three DML commands, one after another
Runs on a fresh IPL practice database in your browser · edit the query and press Ctrl + Enter
Structure stays the same after DML
Runs on a fresh IPL practice database in your browser · edit the query and press Ctrl + Enter
Practice: sign a new player
Runs on a fresh IPL practice database in your browser · edit the query and press Ctrl + Enter
Revision Flashcards
Tap a card to flip it and see the answer.
