SQL INSERT, UPDATE and DELETE Interview Questions
Not every SQL interview is about reading data. Engineering roles also ask you to change it safely: update the right rows, delete without collateral damage and add the right index.
Each question runs your statement on a private copy of the database and then checks the resulting table.
Patterns to know
- UPDATE and DELETE with precise WHERE conditions
- UPDATE using values from another table
- Upserts and skipping duplicates on insert
- Single-column, composite, unique and partial indexes
Easy questions
Medium questions
- Medium DELETE Rows With a Condition Academic Fresh Start Premium
- Medium Skip Duplicates With INSERT OR IGNORE Idempotent Customer Import Free
- Medium UPDATE With CASE Tiered Annual Bonus Premium
- Medium Composite Index on Two Columns The Two-Column Index Premium
- Medium Unique Index One Account per Email Premium
- Medium Copy Rows With INSERT ... SELECT Archive the Churned User Free
- Medium Reassign Rows With UPDATE The Manager Moved On Premium
Hard questions
- Hard UPDATE From Another Table Rebuild the Order Totals Premium
- Hard DELETE Rows With No Match Remove the Ghost Students Premium
- Hard Partial Index Index Only What You Query Premium
- Hard Upsert With INSERT ... ON CONFLICT Upsert the Stock Count Premium
- Hard DELETE Using a Subquery Drop the Legacy Catalog Premium