Change data two ways, by the shape of the WHERE. Name the complete primary key and it's a native single-item write that runs on the first press. Name anything looser — exactly the shape DynamoDB itself refuses — and it becomes a preview-first set-based write: the first Run shows the affected rows, an unchanged second Run applies them, and every write re-checks its predicate atomically.
Syntax
sql
UPDATE "table"SET attr = value [SET attr2 = value2 …] -- repeated SET; attr ± number arithmetic[REMOVE attr] -- drop an attributeWHERE key predicates [AND conditions][RETURNING ALL OLD * | ALL NEW *]
DynamoDB's native clause forms pass through as-is — repeated SET assignments, REMOVE to drop an attribute, attr ± number arithmetic. RETURNING echoes the item before or after the write (single-statement writes only). Guide: Writes & transactions.
Use cases
Change one attribute on one itemNative
The everyday fix — promote a user, stamp the moment it happened.
sql
UPDATE "stage.Users"SET Role = 'admin'SET LastSeen = CURRENT_TIMESTAMPWHERE pk = 'USER#42' AND sk = 'PROFILE'
Executes asUpdateItem · Key: USER#42/PROFILE
The WHERE must name the complete primary key — the editor flags anything looser before it runs (it would become a sweep, below).
Increment a counter in placeNative
Arithmetic SET compiles to a native UpdateExpression — no read-modify-write race.
RETURNING ALL NEW * echoes the item as it stands after the write — no second read.
sql
UPDATE "stage.Users"SET Role = 'admin'WHERE pk = 'USER#42' AND sk = 'PROFILE'RETURNING ALL NEW *
Executes asUpdateItem · ReturnValues: ALL_NEW
ALL OLD * returns the pre-write item instead. Not available inside transactions.
Sweep a whole set (preview-first)Scan — read the note
Archive every dormant account. No key in the WHERE, so this runs as a bulk write: the first Run previews the matching rows (capped at 1,000), an unchanged second Run writes them.
sql
UPDATE "stage.Accounts"SET status = 'archived'WHERE status = 'dormant'
Executes asPreview first → one UpdateItem per row, each re-checking status = 'dormant' as a ConditionExpression
Per-item, not atomic: if a write fails partway, prior writes stand and the status line reports applied / skipped / planned.
A row that changed since the preview is skipped and counted, never blindly overwritten.