UPDATE

On this page

Changes column values in existing rows. WHERE limits the affected rows; without it, every row is updated.

Computed columns can be used in expressions and predicates, but cannot be assignment targets. Update their ordinary source columns to change the derived values.

Syntax

UPDATE <table_name>
SET <col_name> = <expr> [, ...]
[ WHERE <predicate> ]

Examples

Create a table with an event whose channel label needs correction:

CREATE TABLE channel_corrections (event_id string, channel string)
VALUES ('evt-17', 'moblie'), ('evt-42', 'web')
INSERT INTO channel_corrections

Correct only the misspelled value:

UPDATE channel_corrections
SET channel = 'mobile'
WHERE channel = 'moblie'
FROM channel_corrections
ORDER BY event_id
+----------+---------+
| event_id | channel |
+----------+---------+
| evt-17   | mobile  |
| evt-42   | web     |
+----------+---------+