Files
Jack Ye 52684d50b9 docs: flip ownership of View/SQL-client/FTS-SQL/AuthZ/AuthN to OSS, restructure SQL Reference
OSS docs now own the full usage content for features that only run against
an Enterprise deployment, since the client interface itself lives here;
Enterprise docs keep only the parts specific to its own behavior. Sophon's
overlay for these five pages is dropped since the OSS versions are now the
complete reference.

SQL Reference is restructured to match an object-type SQL manual (DDL by
object, then DML, then DQL, then Expressions) instead of the old flat,
loosely-ordered page list, absorbing the SQL client-connection guide and
FTS-via-SQL examples into it.
2026-09-28 17:17:09 -05:00

83 lines
2.3 KiB
Plaintext

---
title: "Update rows"
sidebarTitle: "Update"
description: "Change values in rows that already exist, by predicate or SQL expression."
icon: pen
---
These examples use the table set up in
[Ingesting data](/ingestion), and the connection made there.
import {
PyUpdateOperation as UpdateOperation,
PyUpdateUsingSql as UpdateUsingSql,
TsUpdateOperation,
TsUpdateUsingSql,
RsUpdateOperation,
RsUpdateUsingSql,
} from '/snippets/tables.mdx';
<Note>
In SQL this is [`UPDATE`](/sql/dml/update).
</Note>
## Update rows {#update-rows}
Use `update` when you already know which target rows to modify and you do not need to compare against an incoming dataset.
<CodeGroup>
<CodeBlock filename="Python" language="Python" icon="python">
{UpdateOperation}
</CodeBlock>
<CodeBlock filename="TypeScript" language="TypeScript" icon="square-js">
{TsUpdateOperation}
</CodeBlock>
<CodeBlock filename="Rust" language="Rust" icon="rust">
{RsUpdateOperation}
</CodeBlock>
</CodeGroup>
Expected table contents:
| id | name | login_count |
| --- | --- | --- |
| 1 | Alice | 10 |
| 2 | Bobby | 20 |
<Warning title="Warning">
Updating nested columns is not yet supported.
</Warning>
## Update rows with SQL expressions {#update-rows-with-sql-expressions}
Use `values_sql` when you want to use SQL-like expressions to update rows. This is useful for operations like incrementing a counter, or setting a column value based on another column.
<CodeGroup>
<CodeBlock filename="Python" language="Python" icon="python">
{UpdateUsingSql}
</CodeBlock>
<CodeBlock filename="TypeScript" language="TypeScript" icon="square-js">
{TsUpdateUsingSql}
</CodeBlock>
<CodeBlock filename="Rust" language="Rust" icon="rust">
{RsUpdateUsingSql}
</CodeBlock>
</CodeGroup>
Expected table contents:
| id | name | login_count |
| --- | --- | --- |
| 1 | Alice | 10 |
| 2 | Bob | 21 |
<Note title="SQL syntax">
See the [SQL queries](/sql#connecting) page for more information on the supported SQL syntax.
</Note>
When rows are updated, they are moved out of any existing index. The row will still show up in search queries, but the query will not be as fast as it would be if the row was in the index. If you update a large proportion of rows, consider triggering an index rebuild afterwards.