update to change rows selected by a predicate. Use
merge insert instead when matching an incoming dataset
against existing keys.
Select the rows to change
Check the predicate with a filtered query before applying the update. These examples target the row withid = 2. Review the scope
carefully when omitting a predicate, since that can update the entire table.
Each example below starts from Alice with 10 logins and Bob with 20. The
Python programs create and remove their own temporary database. TypeScript
and Rust operation blocks use db; a complete program is provided below.
Assign a new value
values and TypeScript values arguments take literal values.
Rust’s column argument is an expression, so the string value includes SQL quotes.
Calculate a value from the existing row
values_sql and TypeScript’s valuesSql accept expressions.
These SDK expressions work with LanceDB Embedded tables; they do not require an
Enterprise SQL endpoint. Enterprise also offers UPDATE.
Verify the affected data
Read the selected rows again and inspect the changed fields. For another connection or table handle, account for its read consistency settings. Python’supdate does not compute embeddings. When changing a configured embedding
source column, provide every associated vector column in the same call. This applies
to both literal values and SQL expressions, and to synchronous and asynchronous
tables. Otherwise, the call raises ValueError before writing any rows. Use
merge_insert with the new source values to generate
embeddings automatically.
Nested-field updates are not supported by these operations. For schema changes,
see schema evolution. Treat derived values separately:
changing an input field is not a guarantee that every stored feature has been
recomputed. See Refresh a computed column.
Updates can change index coverage and query cost. After a large update,
inspect the workload and follow index maintenance
guidance for the backend you use.
Complete write workflow
Complete examples: create, append, update, upsert and delete
Complete examples: create, append, update, upsert and delete
Each program creates a temporary local database, performs the five operations,
prints the result, and removes its temporary data when finished.After the operations, Alice has 10 logins, Bobby has 21, and Charlie has 6.
Dana is selected for deletion and is absent from the final result.
- Python: install
lancedb, save the code asingestion.py, and runpython ingestion.py. - TypeScript: install
@lancedb/lancedb, save the code asingestion.mts, and runnode ingestion.mtswith Node.js 22.18 or later. - Rust: download the complete Rust project,
extract it, and run
cargo run --locked. It includessrc/main.rs, the Cargo manifest and a lockfile for the example’s dependencies. The code is shown below.