Data Governance

Data governance features help you manage historical versions, lifecycle, and change tracking for your data. The core capability is Time Travel — based on the MVCC mechanism, every data change retains historical versions, allowing you to query the data state at any point in time, recover accidentally deleted data, or roll back unintended operations.


This Section

PageDescription
Time Travel OverviewTime Travel feature introduction, retention period configuration, supported operations
Time TravelQuick examples: query historical data, roll back a table, recover a dropped table
Time Travel ConceptMVCC working mechanism, three core capabilities (query/recover/rollback), typical scenarios
Data Lifecycle ManagementAutomatically reclaim expired data to control storage costs

Quick Reference

What I want to doMethodReference
Query historical data at a specific point in timeSELECT ... TIMESTAMP AS OF '...'TIME TRAVEL
View the version history of a tableDESC HISTORY table_nameDESC HISTORY
Recover an accidentally dropped tableUNDROP TABLE table_nameUNDROP TABLE
Roll back table data to a historical versionRESTORE TABLE ... TO TIMESTAMP AS OF '...'RESTORE TABLE
Set the number of days to retain historical dataALTER TABLE ... SET PROPERTIES ('data_retention_days'='7')Time Travel Overview
Automatically clean up expired dataALTER TABLE ... SET PROPERTIES ('data_lifecycle'='30')Data Lifecycle Management

Two Easily Confused Concepts

ConceptPurposeParameterDefault
data_retention_daysControls how long Time Travel can access historical versions; versions older than this are physically deleted0–90 days1 day
data_lifecycleControls how long table data survives from its last modification time; data is automatically reclaimed after expiryPositive integer (days)Disabled (-1)

Common Scenarios

Recovering after accidental data deletion

-- Check the row count before the accidental deletion SELECT COUNT(*) FROM orders TIMESTAMP AS OF '2024-01-15 09:59:00'; -- Roll the table back to before the deletion RESTORE TABLE orders TO TIMESTAMP AS OF '2024-01-15 09:59:00';

Recovering after an accidental DROP TABLE

-- View deleted tables SHOW TABLES HISTORY LIKE 'orders%'; -- Recover the table UNDROP TABLE orders;

Tracing data change history

-- View the version history of a table (operator, time, row count) DESC HISTORY orders;