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

  1. Easy INSERT a New Row Stock a New Product Free
  2. Easy UPDATE Rows With a Condition Engineering Gets a Raise Free
  3. Easy UPDATE a Text Value Relabel the Genre Free
  4. Easy Create an Index Speed Up Customer Lookups Free

Medium questions

  1. Medium DELETE Rows With a Condition Academic Fresh Start Premium
  2. Medium Skip Duplicates With INSERT OR IGNORE Idempotent Customer Import Free
  3. Medium UPDATE With CASE Tiered Annual Bonus Premium
  4. Medium Composite Index on Two Columns The Two-Column Index Premium
  5. Medium Unique Index One Account per Email Premium
  6. Medium Copy Rows With INSERT ... SELECT Archive the Churned User Free
  7. Medium Reassign Rows With UPDATE The Manager Moved On Premium

Hard questions

  1. Hard UPDATE From Another Table Rebuild the Order Totals Premium
  2. Hard DELETE Rows With No Match Remove the Ghost Students Premium
  3. Hard Partial Index Index Only What You Query Premium
  4. Hard Upsert With INSERT ... ON CONFLICT Upsert the Stock Count Premium
  5. Hard DELETE Using a Subquery Drop the Legacy Catalog Premium

More SQL interview topics