# UPDATE

[Read this page in HTML](https://www.scopedb.io/docs/reference/commands/statements/update)

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

[Computed columns](https://www.scopedb.io/docs/reference/computed-columns.md) can be used in expressions and predicates, but cannot be assignment targets. Update their ordinary source columns to change the derived values.

## Syntax

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

## Examples

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

```scopeql
CREATE TABLE channel_corrections (event_id string, channel string)
```

```scopeql
VALUES ('evt-17', 'moblie'), ('evt-42', 'web')
INSERT INTO channel_corrections
```

Correct only the misspelled value:

```scopeql
UPDATE channel_corrections
SET channel = 'mobile'
WHERE channel = 'moblie'
```

```scopeql
FROM channel_corrections
ORDER BY event_id
```

```text
+----------+---------+
| event_id | channel |
+----------+---------+
| evt-17   | mobile  |
| evt-42   | web     |
+----------+---------+
```
