Inspect the rows you intend to delete
Use the same predicate for inspection and deletion. The example below creates Alice, Bob and Charlie, prints Charlie’s row, and deletes it byid = 3.
Inspection and deletion are separate operations; concurrent writes can change
which rows match between them.
Delete matching records
Each program creates Alice, Bob and Charlie in a temporary local database, deletes Charlie, and prints the remaining rows: Alice and Bob. The temporary database is removed when the program finishes.- Python: install
lancedb, save the code asdelete_rows.py, and runpython delete_rows.py. - TypeScript: install
@lancedb/lancedb, save the code asdelete_rows.mts, and runnode delete_rows.mtswith Node.js 22.18 or later. - Rust: download the Rust examples,
extract the project, and run
cargo run --locked --bin delete.
DELETE.
Verify that the rows are absent
Query the same predicate after deletion and check the remaining row count. A reader still using an older snapshot may see the earlier contents; see Consistency. Deleted rows are excluded from current query results, including indexed searches. Deletion does not imply immediate physical erasure of every stored copy of the data.Understand storage reclamation
Compaction rewrites the live data layout; cleanup removes eligible retained versions and files. Retained history can continue to reference data that no longer appears in the latest table version. In LanceDB Embedded,optimize() provides maintenance operations. In Enterprise, managed
maintenance and retention follow the service configuration. Choose retention
according to the history you need, rather than shortening it as part of a
routine delete example. See Compaction and
Garbage Collection for the separate maintenance workflow.
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.