Walter_C
Databricks Employee
Databricks Employee

When you restored your Delta table to an earlier version (version 2), you observed that the next inserted row received an ID of 4, not 2. This is because Delta Lake’s identity column maintains a high watermark of the last value used, even across restores. The identity generator is designed to guarantee uniqueness and avoid assigning duplicate values, so it will not reissue previously used identity values-even if the underlying data is reverted to a prior state.

By default, there is no built-in command to reset the identity column’s counter in a Delta table. The identity column will always continue from the highest value it has ever assigned, regardless of table restores, deletes, or truncations.

This behavior is intentional to prevent the risk of duplicate identity values, which could otherwise occur if the counter were allowed to rewind.

The only supported and safe way to reset the identity column is to recreate the table

View solution in original post