---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://ydb.tech/docs/en/yql/reference/syntax/update.md?version=v25.3
  - https://ydb.tech/docs/ru/yql/reference/syntax/update.md?version=v25.3
  - href: en/yql/reference/syntax/update.md
    type: text/markdown
    title: Markdown version
  - href: ../../../llms.txt
    type: text/markdown
    title: llms.txt
sourcePath: en/core/yql/reference/syntax/update.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ydb.tech/docs/en/llms.txt

# UPDATE

<!-- source: en/_includes/limitation-column-row-in-read-only-tx-warn.md -->
{% note warning %}

<!-- source: en/_includes/limitation-column-row-in-read-only-tx.md -->
Currently, mixing [column-oriented tables](https://ydb.tech/docs/en/concepts/glossary.md?version=v25.3#column-oriented-table) and [row-oriented tables](https://ydb.tech/docs/en/concepts/glossary.md?version=v25.3#row-oriented-table) in a single transaction is supported only if the transaction performs read operations; no writes are allowed. Support for read-write transactions involving both table types is under development.

If a write transaction includes both types of tables, it fails with the following error: `Write transactions that use both row-oriented and column-oriented tables are disabled at current time`.
<!-- endsource: en/_includes/limitation-column-row-in-read-only-tx.md -->

{% endnote %}
<!-- endsource: en/_includes/limitation-column-row-in-read-only-tx-warn.md -->

Updates the data in the table. After the `SET` keyword, enter the columns where you want to update values and the new values themselves. The list of rows is defined by the `WHERE` clause. If `WHERE` is omitted, the updates are applied to all the rows of the table.

`UPDATE` can't change the value of the primary key columns.

## Example

```yql
UPDATE my_table
SET Value1 = YQL::ToString(Value2 + 1), Value2 = Value2 - 1
WHERE Key1 > 1;
```

## UPDATE ON {#update-on}

Updates the data in the table based on the results of a subquery. The set of columns returned by the subquery must be a subset of the table's columns being updated, and all columns of the table's primary key must be present in the returned columns. The data types of the columns returned by the subquery must match the data types of the corresponding columns in the table.

The primary key value is used to search for the rows being updated. For each row found, the values of the non-key columns is replaced with the values returned in the corresponding row of the result of the subquery. The values of the table columns that are missing in the returned columns of the subquery remain unchanged.

### Example

```yql
$to_update = (
    SELECT Key, SubKey, "Updated" AS Value FROM my_table
    WHERE Key = 1
);

UPDATE my_table ON
SELECT * FROM $to_update;
```


## See also

* [BATCH UPDATE](https://ydb.tech/docs/en/yql/reference/syntax/batch-update.md?version=v25.3)

