What is INSERT, UPDATE, and DELETE in SQL?

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 WHEREDELETE 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.