Basic Versioning Example
Let’s create a table with sample data to demonstrate LanceDB’s versioning capabilities:Set Up the Table
First, let’s create a table with some sample data:Check Initial Version
After creating the table, let’s check the initial version information:Modify Data
When you modify data through operations like update or delete, LanceDB automatically creates new versions.Update Existing Data
Let’s update some existing records to see versioning in action:Add New Data
Now let’s add more records to the table:Check Version Changes
Let’s see how the versions have changed after our modifications:Rollback to Previous Versions
LanceDB supports fast rollbacks to any previous version without data duplication.View All Versions
First, let’s see all the versions we’ve created:Restore a Version Snapshot
Now let’s restore a captured version snapshot:Delete Data From the Table
Let’s demonstrate how deletions also create new versions:Go Back to Latest Version
First, let’s return to the latest version:Delete Data
Now let’s delete some data to see how it affects versioning:Version History and Operations
On a fresh table, the snippets in this guide produce this version sequence:v1: create table (create_table/createTable/create_table)v2: update rows (update)v3: add rows (add)v4: restore snapshot (restore) fromversion_after_mod/versionAfterModv5: delete rows (delete)
list_versions/listVersions, version, checkout, checkout_latest/checkoutLatest) do not create new versions.
System OperationsSystem operations like
optimize(), index updates, and table compaction also increment table version numbers.
In LanceDB OSS and Cloud, optimize() can prune older versions based on its retention setting (cleanup_older_than, 7 days by default),
which is when old-version files are removed and disk space is reclaimed.