INSERT, UPDATE, and DELETE change table rows. Unlike a SELECT, a write statement can permanently affect data, so first verify its target rows and understand transaction support before running it against important data.
Key Takeaways at a Glance:
- •DML statements mutate data: INSERT creates rows, UPDATE modifies rows, and DELETE removes rows.
- •THE GOLDEN RULE OF UPDATE & DELETE: Always write and verify the WHERE clause with a SELECT query first before executing a destructive change.
- •An UPDATE or DELETE without a WHERE clause modifies or purges EVERY SINGLE ROW in the entire table.
- •Use transactions (BEGIN ... COMMIT / ROLLBACK) to verify row counts before permanently committing data modifications.
In Simple Words (The Mental Model)
INSERT puts new records into a table. UPDATE edits existing records. DELETE removes records. Because UPDATE and DELETE operate on whatever matches your WHERE clause, forgetting the WHERE clause will wipe out or overwrite your entire company's database in a fraction of a second!
Real-World Analogy
Think of an office paper shredder. If you tell an intern: 'Shred the invoices WHERE client = Acme' (targeted DELETE), they only shred Acme's papers. If you say 'Shred the invoices' without pointing to which ones, they shred the entire file cabinet (accidental table wipeout).