BigQuery · DML statement
BigQuery UPDATE
UPDATE changes column values in existing BigQuery rows. The WHERE clause is mandatory (use WHERE TRUE to update every row), and UPDATE ... FROM joins another table. On-demand it bills the bytes read plus the full size of the table, or of the partitions being updated.
UPDATE table SET col = expression, ... WHERE condition rewrites the rows that match. Unlike most databases, BigQuery rejects an UPDATE without WHERE; to update every row on purpose, write WHERE TRUE. A STRUCT field is set with dot notation (SET address.city = 'Berlin'), and a repeated field is replaced as a whole array, often rebuilt with ARRAY(SELECT AS STRUCT ... FROM UNNEST(...)).
UPDATE target SET ... FROM source WHERE target.key = source.key updates from another table or subquery; the join condition goes in WHERE (the FROM join is an inner join when WHERE has a condition, a cross join otherwise). Each target row may match at most one source row: if one matches several, the statement fails with UPDATE/MERGE must match at most one source row for each target row. Target rows without a match are left alone. If a column name exists in both tables, qualify it, or the reference is ambiguous.
Every UPDATE is an implicit transaction and a mutating DML statement: BigQuery runs up to two per table at a time and queues up to 20 more. Two concurrent UPDATEs that touch the same partition conflict; BigQuery retries them, and they can fail with Could not serialize access to table due to concurrent update. Rows streamed in the last 30 minutes through the legacy tabledata.insertAll API cannot be updated yet (DML over the streaming buffer).
Cost is the part that surprises people. On-demand an UPDATE bills the bytes the statement reads plus the size of the whole table before the change, or, for a partitioned table, of every partition being updated. Changing one row in an unpartitioned 1 TiB table bills more than 1 TiB, about $6.25 at $6.25 per TiB. Partition tables that you update and filter UPDATEs on the partitioning column, so only those partitions count.
Syntax
UPDATE target_table [[AS] alias]
SET column = expression[, ...]
[FROM from_item]
WHERE conditionArguments and return value
| Argument | Description |
|---|---|
target_table | The table to change. Not a view or a wildcard table. |
SET | Columns and new values; expressions can use the target's columns and those of the FROM items. DEFAULT sets the column default. |
FROM | Optional table, subquery or join to read new values from. Put the join condition in WHERE; each target row may match at most one row. |
WHERE | Required. Selects the rows to update; WHERE TRUE updates all rows. |
Returns: No result set. Job statistics report updated_row_count (dml_statistics in INFORMATION_SCHEMA.JOBS).
Examples
Update with a partition filter
orders is partitioned by DATE(created_at). Limiting the UPDATE to one week means only those seven partitions are billed and rewritten.
UPDATE `project.dataset.orders`
SET status = 'cancelled', updated_at = CURRENT_TIMESTAMP()
WHERE status = 'pending'
AND created_at >= '2026-11-16' AND created_at < '2026-11-23'
AND payment_deadline < CURRENT_TIMESTAMP();Update from another table
Each order gets its customer's current country. The join condition is in WHERE; customers must have one row per customer_id.
UPDATE `project.dataset.orders` AS o
SET country = c.country
FROM `project.dataset.customers` AS c
WHERE o.customer_id = c.customer_id
AND DATE(o.created_at) = '2026-11-22'
AND o.country IS DISTINCT FROM c.country;Update a STRUCT field and an array of structs
UPDATE `project.dataset.orders`
SET
shipping.city = INITCAP(shipping.city),
items = ARRAY(
SELECT AS STRUCT i.* REPLACE (UPPER(i.sku) AS sku)
FROM UNNEST(items) AS i
)
WHERE DATE(created_at) = '2026-11-22';Every row, on purpose
WHERE is mandatory, so updating all rows has to be explicit. On-demand this bills at least the full table size.
UPDATE `project.dataset.products`
SET currency = 'EUR'
WHERE TRUE;Common mistakes
- Leaving out WHERE.
UPDATE t SET x = 1fails with "UPDATE must have a WHERE clause"; add the condition, orWHERE TRUEfor all rows. - Updating from a source with duplicate keys. One target row matching two source rows fails the statement; deduplicate the FROM side with GROUP BY or QUALIFY first.
- Running many small UPDATEs, one per row or per entity. Each one bills the size of the table or partitions it touches and they queue per table; collect changes in a staging table and apply them with one UPDATE ... FROM or MERGE.
- Filtering only on a non-partition column. Without a partition filter the UPDATE bills the whole table even if it changes one row.
- Writing the SQL Server form
UPDATE t SET ... FROM t JOIN s ON .... In BigQuery, list the source in FROM and the join condition in WHERE; if the target appears in FROM again it needs an alias and becomes a self-join.
Cost and performance
- On-demand bytes billed for an UPDATE are the bytes read by the statement plus the size of the table (or of the partitions being updated) before the change. Partition the table and filter on the partitioning column; cluster it on the columns you filter by so fewer blocks are rewritten.
- An UPDATE rewrites the storage it touches, which restarts the 90-day timer for long-term storage in those partitions. Avoid recurring UPDATEs on old partitions you want to keep in cheaper storage.
- Mutating DML on one table is serialized: two run concurrently and 20 can wait. Frequent small UPDATEs from many workers end in Too many DML statements outstanding.
FAQ
How do I update all rows in BigQuery?
Write UPDATE t SET col = value WHERE TRUE. BigQuery requires a WHERE clause on every UPDATE.
How do I update a table from another table in BigQuery?
UPDATE target t SET col = s.col FROM source s WHERE t.id = s.id. The source must have at most one row per target row. For insert-or-update in one step, use MERGE.
How much does an UPDATE cost in BigQuery?
On-demand it bills the bytes it reads plus the size of the table being updated, or of the updated partitions if the table is partitioned. On capacity pricing it uses slots for the read and the rewrite.
Related
Errors you may hit
More DML statements
All BigQuery DML statements · All statements and clauses · BigQuery error messages
