Time Travel is the core data-protection feature of Snowflake. It lets you access the past state of tables, schemas, and databases so you can recover from mistakes and query historical data. The three points that come up most often on the exam are: past-point-in-time queries with the AT/BEFORE clause, object restoration with UNDROP, and retention control with DATA_RETENTION_TIME_IN_DAYS.
The Time Travel retention period is controlled by the DATA_RETENTION_TIME_IN_DAYS parameter. This value can be set at the account, database, schema, and table levels, and lower-level settings override higher-level ones.
| Edition | Permanent Table | Transient Table | Temporary Table |
|---|---|---|---|
| Standard | 0-1 day | 0-1 day | 0-1 day |
| Enterprise and above | 0-90 days | 0-1 day | 0-1 day |
-- Set retention to 90 days at the table level
ALTER TABLE analytics.orders
SET DATA_RETENTION_TIME_IN_DAYS = 90;
-- Set retention at the schema level (becomes the default for tables under it)
ALTER SCHEMA analytics
SET DATA_RETENTION_TIME_IN_DAYS = 30;
-- Check the current setting
SHOW PARAMETERS LIKE 'DATA_RETENTION_TIME_IN_DAYS'
IN TABLE analytics.orders;The AT clause returns the state at the specified point in time, while the BEFORE clause returns the state immediately before the specified point. There are three patterns: timestamp, offset, and Statement ID.
-- AT: get the state at the specified timestamp
SELECT *
FROM analytics.orders
AT (TIMESTAMP => '2026-03-27 09:00:00'::TIMESTAMP_NTZ);
-- BEFORE: get the state immediately before the specified timestamp
SELECT *
FROM analytics.orders
BEFORE (TIMESTAMP => '2026-03-27 09:00:00'::TIMESTAMP_NTZ);-- Get the state from 30 minutes ago
SELECT *
FROM analytics.orders
AT (OFFSET => -60 * 30);
-- Get the state from 2 hours ago
SELECT COUNT(*) AS row_count_2h_ago
FROM analytics.orders
AT (OFFSET => -60 * 60 * 2);-- Get the state immediately before a specific DML statement (ideal for mistake recovery)
SELECT *
FROM analytics.orders
BEFORE (STATEMENT => '01b12345-0600-1234-0000-abcdef012345');Statement IDs are available from the QUERY_HISTORY view. If you accidentally run an UPDATE/DELETE, specifying that Statement ID in a BEFORE clause lets you roll back to the exact state immediately before that operation.
-- Pattern 1: recover from a bad UPDATE (CLONE + SWAP)
CREATE TABLE analytics.orders_restored
CLONE analytics.orders
BEFORE (STATEMENT => '01b12345-0600-1234-0000-abcdef012345');
-- After verifying the restored table, swap the tables
ALTER TABLE analytics.orders RENAME TO analytics.orders_backup;
ALTER TABLE analytics.orders_restored RENAME TO analytics.orders;
-- Pattern 2: recover only specific rows (partial recovery)
INSERT INTO analytics.orders
SELECT * FROM analytics.orders
BEFORE (STATEMENT => '01b12345-0600-1234-0000-abcdef012345')
WHERE order_id IN (1001, 1002, 1003);Dropped objects can be restored with UNDROP as long as they are still within the retention period. UNDROP is available at three levels: table, schema, and database.
-- Restore a table
DROP TABLE analytics.orders;
UNDROP TABLE analytics.orders;
-- Restore a schema (also restores every table under it)
DROP SCHEMA analytics;
UNDROP SCHEMA analytics;
-- Restore a database (also restores every schema and table under it)
DROP DATABASE sales_db;
UNDROP DATABASE sales_db;If an object with the same name has already been re-created, UNDROP fails. In that case, rename the existing object first and then run UNDROP.
-- Restore procedure when a table with the same name already exists
ALTER TABLE analytics.orders RENAME TO analytics.orders_new;
UNDROP TABLE analytics.orders;Fail-safe is an additional 7-day data-protection layer that takes over after the Time Travel period ends. It is fundamentally different from Time Travel and cannot be operated on by users directly.
| Comparison Item | Time Travel | Fail-safe |
|---|---|---|
| Operated by | User (via SQL) | Snowflake Support only |
| Period | 0-90 days (configurable) | Fixed 7 days (after Time Travel) |
| Applicable tables | Permanent / Transient / Temporary | Permanent only |
| Storage cost | Cost of change history | Cost of change history (Permanent only) |
| Recovery method | AT/BEFORE clause, UNDROP, CLONE | Contact Snowflake Support |
|<── Time Travel (0-90 days) ──>|<── Fail-safe (7 days) ──>|
| Users can freely query / restore | Snowflake Support only |
Example: Enterprise Edition / DATA_RETENTION = 90 days / Permanent Table
-> Up to 97 days of data protection (90 + 7)
Example: Standard Edition / DATA_RETENTION = 1 day / Permanent Table
-> Up to 8 days of data protection (1 + 7)
Example: Transient Table (all editions)
-> Up to 1 day of Time Travel, no Fail-safe| Table Type | Time Travel | Fail-safe | Primary Use |
|---|---|---|---|
| Permanent (default) | 0-90 days | 7 days | Production data and tables that need protection |
| Transient | 0-1 day | None | Intermediate tables and regeneratable data |
| Temporary | 0-1 day | None | Temporary work limited to a single session |
Data Protection
問題 1
While using Enterprise Edition, you accidentally deleted some rows from a table with a bad DELETE statement. You have already identified the offending Statement ID from QUERY_HISTORY. Which is the most appropriate way to recover the data?
正解: B
BEFORE (STATEMENT => ...) lets you access the table state immediately before the offending DELETE. Creating a restored table with CLONE and then INSERTing only the deleted rows back into the original table is the most appropriate approach. Fail-safe cannot be operated on directly by users, and COPY_HISTORY is a file-load history that cannot be used to recover from DML operations.
How much does storage cost increase when I extend the Time Travel retention period?
Extending the Time Travel retention period causes Snowflake to retain micro-partition change history for the entire window, which incurs additional storage cost. The exact increase depends on how often DML runs and how much data changes. For tables with frequent UPDATE/DELETE operations, each operation preserves the pre-change micro-partitions, so a 90-day retention setting can consume several times more storage than a 1-day setting. We recommend regularly monitoring the TIME_TRAVEL_BYTES column in the TABLE_STORAGE_METRICS view.
When I restore with UNDROP, are table privileges (GRANTs) and Clustering Keys also restored?
Yes. UNDROP TABLE restores not only the table data but also metadata such as the GRANT privileges assigned to the table, Clustering Keys definitions, comments, and tags. UNDROP SCHEMA / UNDROP DATABASE likewise restores every object inside the schema or database along with its privilege information. However, UNDROP fails if an object with the same name already exists, so you must first rename the existing object with ALTER TABLE ... RENAME TO.
Can Time Travel be used on Transient Tables and Temporary Tables?
Transient Tables support up to 1 day of Time Travel (DATA_RETENTION_TIME_IN_DAYS = 0 or 1) but have no Fail-safe period. Temporary Tables also support up to 1 day of Time Travel within a session and are automatically dropped when the session ends. Even on Enterprise Edition, Transient and Temporary Tables are capped at 1 day of retention; extending retention up to 90 days is only possible for Permanent Tables.
Practice with certification-focused question sets
無料で問題を解いてみるNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
Snowflake Certifications: All 11 Exams Explained (2026)
Every SnowPro certification — Associate, Core, Specialty, Ad...
Snowflake Exam Difficulty Ranking: All 11 Certs Compared (2026)
All 11 SnowPro exams ranked by difficulty with study-time es...
Snowflake Study Guide: Fastest Pass Route by Exam (2026)
How to pass SnowPro certifications efficiently — official ma...
SnowPro Core (COF-C03): Complete Exam Guide (2026)
Pass the SnowPro Core exam — six domains, scope, sample ques...
SnowPro Associate Platform (SOL-C01): Complete Guide (2026)
The entry-level SnowPro Associate exam — scope, weighting, s...