What is INSERT, UPDATE, and DELETE in SQL?
Why Interviewers Ask This
Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for MySQL / SQL development. It reveals whether you understand the building blocks that more complex concepts rely on.
Answer
INSERT adds new rows to a table: INSERT INTO users (name, email, age) VALUES ("Alice", "alice@example.com", 30); — specify columns and matching values. Insert multiple rows: INSERT INTO users (name, email) VALUES ("Bob", "b@b.com"), ("Carol", "c@c.com");. UPDATE modifies existing rows: UPDATE users SET status = "inactive", updated_at = NOW() WHERE id = 5;. Always include a WHERE clause with UPDATE — omitting it updates ALL rows in the table. Verify with SELECT first: SELECT * FROM users WHERE id = 5; then UPDATE the same condition. DELETE removes rows: DELETE FROM users WHERE id = 5;. Again, always include WHERE — DELETE FROM users; with no WHERE removes every row. For removing all rows while resetting auto-increment, use TRUNCATE instead. Safe practice: wrap destructive operations in a transaction so you can ROLLBACK if something goes wrong. Use LIMIT in UPDATE/DELETE to cap affected rows as a safety measure.
Common Mistake
Don't just define the term — demonstrate that you understand when to use it and when not to. Showing awareness of trade-offs is what separates average from strong MySQL / SQL candidates.