Help Center/ Data Lake Insight/ Delta SQL Syntax Reference/ Delta Time Travel/ Querying History Version Data of a Delta Table
Updated on 2025-01-09 GMT+08:00

Querying History Version Data of a Delta Table

Syntax

Query the state of a Delta table at a specific point in time:

SELECT * FROM [database_name.]table_name

TIMESTAMP AS OF timestamp_expression

Query the state of a Delta table at a specific historical version:

SELECT * FROM [database_name.]table_name VERSION AS OF version_code

Parameter Description

Table 1 Parameters for querying historical versions of a Delta table

Parameter

Description

database_name

Name of the database, consisting of letters, numbers, and underscores (_)

table_name

Name of the table in the database, consisting of letters, numbers, and underscores (_)

timestamp_expression

Timestamp, which cannot be later than the current time, formatted as yyyy-MM-ddTHH:mm:ss.SSS

version_code

Version number in the query result in Viewing History Operation Records of a Delta Table

Example

SELECT * FROM delta_table0 TIMESTAMP AS OF '2020-10-18T22:15:12.013Z';
SELECT * FROM delta_table0 VERSION AS OF 2 where part_col='part_value';