Introduction
Imagine you have a list of contacts on paper, and you want to add new friends, change phone numbers, or remove old contacts. Managing data in a database works similarly, and DML commands help you do these tasks easily.
Think of a notebook where you keep your friends' contact details. When you meet a new friend, you write their info down (INSERT). If they change their phone number, you cross out the old one and write the new number (UPDATE). If you lose touch, you erase their details (DELETE).
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ INSERT │──────▶│ UPDATE │──────▶│ DELETE │ │ Add records │ │ Modify data │ │ Remove data │ └─────────────┘ └─────────────┘ └─────────────┘
CREATE TABLE contacts (id INT, name TEXT, phone TEXT); INSERT INTO contacts (id, name, phone) VALUES (1, 'Alice', '12345'); UPDATE contacts SET phone = '67890' WHERE id = 1; DELETE FROM contacts WHERE id = 1;