# SQL Level 7: Data Modification

> Level 7: Data Modification of the LoWisa SQL course: INSERT, UPDATE and DELETE, Upserts and Merge Patterns, Safe Data Changes. 3 lessons and 9 ideas, each explained in one line.

Data Modification is level 7 of 15 of the [LoWisa SQL course](/courses/sql/). It has 3 lessons and 9 ideas. Below is every lesson and what it teaches, in one line each.

## INSERT, UPDATE and DELETE

- **INSERT.** **INSERT** adds rows: with explicit column lists, so a reordered schema cannot silently shift your values.
- **UPDATE with WHERE.** **UPDATE** rewrites matching rows: and an UPDATE without WHERE rewrites the entire table, so look twice.
- **DELETE carefully.** **DELETE** removes matching rows: professionals SELECT with the same WHERE first to see what will go.

## Upserts and Merge Patterns

- **Upsert.** An **upsert**: INSERT with ON CONFLICT: inserts a new row or updates the existing one atomically.
- **Idempotent loads.** Data loads built on upserts are **idempotent**: replaying yesterday’s file cannot double anything.
- **RETURNING.** The **RETURNING** clause hands back what a write produced: new ids without a second round trip.

## Safe Data Changes

- **Wrap in transactions.** Risky changes run inside a **transaction**: verify the counts, then COMMIT: or ROLLBACK and nothing happened.
- **Backfill in batches.** Mass updates run in **batches**: a million-row single statement locks tables and bloats logs.
- **Audit trails.** Serious systems record who changed what: an **audit** table or soft deletes preserving history.

## Before and after this level

- **Before:** [Level 6: Window Functions](/courses/sql/level-6-window-functions/): Ranking and Partitioning, Running and Moving Calculations, Advanced Analytical Queries.
- **Next:** [Level 8: Schema Design](/courses/sql/level-8-schema-design/): Tables and Data Types, Keys and Constraints, Normalisation and Relationships.

In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See [Checkpoints and flashcards](/help/checkpoints-and-flashcards/).

## Frequently asked questions

### What does SQL Level 7: Data Modification cover?

INSERT, UPDATE and DELETE, Upserts and Merge Patterns, Safe Data Changes: 3 lessons and 9 ideas.

### What should I know before this level?

The level before it, Level 6: Window Functions, which covers Ranking and Partitioning, Running and Moving Calculations, Advanced Analytical Queries.

## Learn SQL on your phone

The first level is free. LoWisa is on Google Play and the App Store.

---

Source: https://lowisa.dev/courses/sql/level-7-data-modification/ · Updated 2026-11-16
