Manuals / SQL / Chapter 8

C · Write · intermediate · Week 3 · Chapter 8 of 12

INSERT, UPDATE, DELETE safely

Never UPDATE/DELETE without WHERE. SELECT first to preview rows. Use transactions for multi-step changes.

Path progress
61%

Step 1 of 3

INSERT

INSERT INTO users (name, email) VALUES (...). INSERT ... SELECT for bulk copies.

INSERTDrag stickies · tap for tips
Study mapDrag stickies · tap for tipsKeep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Assert the UIdrag · tap →Retry wiselydrag · tap →Seed datadrag · tap →Close the loopdrag · tap →Keep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Pathwise hackdrag · tap →INSERTdrag · tap →Try thisdrag · tap →Follow the dashed drag · tap →

Example

INSERT INTO users (name, email, active)
VALUES ('Test User', 'test@example.com', 1);

Do this now

Insert 3 test rows into a sandbox table.

Was this step clear?
Chapter learning outcomes
  • INSERT
  • UPDATE ... WHERE
  • DELETE ... WHERE
  • Safety ritual

Clear these before you leave

Side quest

Soft delete

UPDATE active=0 instead of DELETE; query active users only.