Snowflake's continuous data protection layer answers a single operational question: when a row, table, or schema is corrupted or dropped by accident, how does the platform get it back without restoring from a backup tape, a snapshot policy, or a point-in-time recovery wizard. The answer is that Snowflake retains a record of every change to a table for a configurable window, then provides three SQL primitives, the AT clause, the BEFORE clause, and the UNDROP statement, to read or restore data inside that window.
The retention window is driven by the DATA_RETENTION_TIME_IN_DAYS parameter, which is set per object and inherits from the parent if no explicit value is supplied. Behind the scenes, the storage layer keeps the older micro-partitions for the retention duration, and the cloud services layer rewires query plans to read those older partitions when an AT or BEFORE clause is supplied.
Because the older partitions are already in centralized storage, there is no separate snapshot to restore, no failover window, and no service to provision. The retention is continuous, not scheduled.
Time Travel is the name Snowflake gives to the user-queryable portion of this window. Time Travel covers the days configured on DATA_RETENTION_TIME_IN_DAYS, from a minimum of 0 days (which disables Time Travel for the object) to a maximum of 1 day on Standard edition and 90 days on Enterprise edition or higher for permanent tables.
After Time Travel expires, the partitions move into Fail-safe, a 7-day Snowflake-managed recovery window that is not queryable from SQL and exists only for catastrophic recovery by Snowflake support. Fail-safe applies to permanent tables only.
Transient and temporary tables move directly to deletion after Time Travel expires, with no Fail-safe at all. The reader who confuses Time Travel with Fail-safe will fail at least one question on the exam: Time Travel is the SQL-queryable window, Fail-safe is the support-only window that follows.
The AT and BEFORE clauses are the read primitives. They attach to a table reference in a SELECT statement, a CREATE TABLE AS SELECT, or a clone, and they accept three forms: TIMESTAMP, OFFSET, and STATEMENT.
- The TIMESTAMP form names an absolute moment.
- The OFFSET form names a relative duration in seconds before the present.
- The STATEMENT form names a specific query ID.
The difference between AT and BEFORE is a single tick of the clock: AT means at or after the moment, BEFORE means strictly before the moment.
In practice, AT is what almost every recovery query uses, because the operator knows the timestamp the corruption happened and wants to read the table as it stood at that moment. BEFORE is what an operator uses to read the table as it stood just before a known bad statement ran, identified by the statement's query ID from the Query History view.
How it works
UNDROP is the restore primitive. It applies to tables, schemas, and databases and reverses a DROP that occurred within the retention window. The restored object reappears in place with its original name, owner, grants, and Time Travel state.
UNDROP requires that the parent container still exist:
- UNDROP TABLE works only if the schema and database still exist.
- UNDROP SCHEMA works only if the database still exists.
- UNDROP DATABASE works only against the account.
If the parent has also been dropped, UNDROP the parent first, then UNDROP the child. UNDROP does not need a timestamp argument because it always restores the most recently dropped object with that name. If two tables with the same name were dropped within the window, UNDROP restores the latest drop, and the earlier drop is no longer recoverable by UNDROP alone.
DATA_RETENTION_TIME_IN_DAYS configuration
The DATA_RETENTION_TIME_IN_DAYS parameter is set at four levels: account, database, schema, and table.
The value at the lowest level wins, and lower levels inherit from the parent if they do not specify a value of their own.
Limits and quotas
- On Standard edition the maximum value is 1.
- On Enterprise edition and higher the maximum is 90 for permanent tables.
- The value can always be set to 0 to disable Time Travel for that object.
Transient tables and temporary tables cap at 1 day regardless of edition, because they have no Fail-safe and the platform does not retain older partitions beyond that.
Setting the parameter at the account level establishes a default that propagates to every database created without an explicit value. Setting it on a database propagates to schemas and tables in that database, and setting it on a schema propagates to tables in that schema.
-- Inspect the current retention setting at each scope
SHOW PARAMETERS LIKE 'DATA_RETENTION_TIME_IN_DAYS' IN ACCOUNT;
SHOW PARAMETERS LIKE 'DATA_RETENTION_TIME_IN_DAYS' IN DATABASE analytics_db;
SHOW PARAMETERS LIKE 'DATA_RETENTION_TIME_IN_DAYS' IN SCHEMA analytics_db.public;
SHOW PARAMETERS LIKE 'DATA_RETENTION_TIME_IN_DAYS' IN TABLE analytics_db.public.orders;
-- Set a 7 day retention on a database (Enterprise edition required)
ALTER DATABASE analytics_db
SET DATA_RETENTION_TIME_IN_DAYS = 7;
-- Override down to 1 day on a high-volume audit table
ALTER TABLE analytics_db.public.access_log
SET DATA_RETENTION_TIME_IN_DAYS = 1;
-- Disable Time Travel on a churn-heavy staging table
ALTER TABLE analytics_db.public.staging_events
SET DATA_RETENTION_TIME_IN_DAYS = 0;
The parameter affects storage cost because the platform retains older micro-partitions for the configured number of days. A table with heavy UPDATE and DELETE traffic and a 90-day retention can hold significantly more storage than its current row count suggests, because every overwritten micro-partition stays available for the entire window.
The right choice for any given table balances recovery requirements against storage cost: a slowly-changing dimension table tolerates a 30-day or 90-day window cheaply, while a transient staging table that churns every batch is better with 0 or 1 day.
📊 Limit: DATA_RETENTION_TIME_IN_DAYS ranges from 0 to 1 on Standard edition and 0 to 90 on Enterprise edition or higher for permanent tables. Transient and temporary tables cap at 1 day regardless of edition.
📊 Limit: Fail-safe is a fixed, non-configurable 7-day window that begins when Time Travel expires for a permanent table. Fail-safe is not user-queryable and is recoverable only by Snowflake Support.
Reading historical data with AT and BEFORE
Both clauses attach to a table reference and shift the read to the specified point in the retention window. Three forms are accepted:
- TIMESTAMP for an absolute moment
- OFFSET for a relative number of seconds in the past
- STATEMENT for a specific query ID
The OFFSET value is negative for the past and is expressed in seconds. The STATEMENT form accepts the query ID string of a previously executed statement.
-- AT TIMESTAMP: read the table as it stood at an absolute moment
SELECT *
FROM analytics_db.public.orders
AT(TIMESTAMP => '2099-07-15 14:30:00'::TIMESTAMP_LTZ)
WHERE order_id = 50123;
-- AT OFFSET: read the table as it stood 30 minutes ago
SELECT COUNT(*) AS recent_count
FROM analytics_db.public.orders
AT(OFFSET => -1800);
-- BEFORE STATEMENT: read the table as it stood just before a known bad query
SELECT *
FROM analytics_db.public.orders
BEFORE(STATEMENT => '01a2b3c4-5678-90ab-cdef-1234567890ab');
-- Recover from a bad UPDATE by re-loading rows from the pre-statement state
CREATE OR REPLACE TABLE analytics_db.public.orders_recovered AS
SELECT *
FROM analytics_db.public.orders
BEFORE(STATEMENT => '01a2b3c4-5678-90ab-cdef-1234567890ab');
The AT and BEFORE clauses can be combined with joins, aggregations, and filters in the same way as any other table reference, and they can be combined across multiple tables in a single query to compare a present-day row with its historical version. They can also be used inside CREATE TABLE AS SELECT or CREATE TABLE ...
CLONE to materialize a historical state into a new object, which is the typical pattern for full table recovery: rather than overwrite the live table in place, the operator clones the historical state into a recovery table, validates the rows, then swaps the table names with ALTER TABLE ... SWAP WITH.
The most common recovery sequence after a bad DML statement runs uses Query History to find the statement's query ID, BEFORE STATEMENT to read the pre-change state, and either INSERT INTO the original table with the recovered rows or a CREATE TABLE ... CLONE to materialize a parallel copy.
The query ID is the safest reference point because it is precise to the statement, whereas TIMESTAMP and OFFSET can race against concurrent traffic and read slightly later partitions.
UNDROP and recovery semantics
UNDROP reverses the most recent DROP for an object name within the retention window. It is the only Time Travel primitive that does not take a timestamp or offset argument, because the platform always restores the most recent drop that is still within the window.
-- Drop and undrop a table
DROP TABLE analytics_db.public.orders;
UNDROP TABLE analytics_db.public.orders;
-- Drop and undrop a schema
DROP SCHEMA analytics_db.staging;
UNDROP SCHEMA analytics_db.staging;
-- Drop and undrop a database
DROP DATABASE archive_db;
UNDROP DATABASE archive_db;
-- If both a table and its schema were dropped, restore the schema first
UNDROP SCHEMA analytics_db.staging;
UNDROP TABLE analytics_db.staging.raw_events;
If two tables with the same name and same parent schema were both dropped within the retention window, only the most recently dropped table is restored by UNDROP TABLE. The earlier drop is no longer accessible by name.
If both must be recovered, the operator UNDROPs the most recent first, renames it to a recovery name, then UNDROPs the older copy.
Snowflake offers no way to enumerate dropped objects from SQL alone in a way that exposes both copies by query: the SHOW TABLES HISTORY command does list dropped tables with their drop timestamp and remaining retention, and is the canonical way to inspect what is recoverable.
-- List dropped tables and remaining retention
SHOW TABLES HISTORY IN SCHEMA analytics_db.public;
-- Inspect dropped schemas across a database
SHOW SCHEMAS HISTORY IN DATABASE analytics_db;
-- Inspect dropped databases across the account
SHOW DATABASES HISTORY;
The HISTORY keyword on these SHOW commands returns rows for both live and dropped objects, with a dropped_on column that is non-null for dropped objects and a retention_time column that names the configured retention in days.
💡 Exam Trap: UNDROP never accepts a timestamp or statement argument. It always restores the most recent drop. If the exam shows
UNDROP TABLE orders AT(TIMESTAMP => ...)as an answer choice, it is wrong.
💡 Exam Trap: UNDROP requires the parent container to exist. If a question asks about restoring a table whose schema was also dropped, the correct sequence is UNDROP SCHEMA first, then UNDROP TABLE. The reverse order returns an object-not-found error because the schema namespace does not exist at the time of the table UNDROP.
⚠️ Anti-Pattern: Setting DATA_RETENTION_TIME_IN_DAYS to 90 on every table by account-wide default to maximize recoverability. High-churn tables generate large historical partition footprints, and the storage bill grows non-linearly with retention. The correct pattern is to tier retention by table role: long retention on slowly-changing reference tables, short retention on churning staging tables, and 0 days on tables that are recoverable from upstream.
🎯 Scenario: An analyst overwrites the
orderstable withUPDATE orders SET status = 'cancelled'because the WHERE clause was missing. The team has the query ID from Query History. UsingBEFORE(STATEMENT => '<query_id>')they read the pre-change state into a clone table namedorders_recovered, validate the row counts and status distribution against the previous day's report, then runALTER TABLE orders SWAP WITH orders_recoveredto swap the names. The clone took milliseconds because it shared micro-partitions with the historical state, and the swap operation is metadata-only.
💡 Exam Trap: Time Travel covers permanent tables for up to 90 days on Enterprise edition, but transient and temporary tables cap at 1 day regardless of edition. A question that asks for "the maximum Time Travel retention on a transient table in an Enterprise account" is testing this distinction. The answer is 1 day, not 90.
Decision Anchor
Choose Time Travel with the AT or BEFORE clause when a logical error has been made within the retention window and the affected rows can be identified by timestamp or statement.
Choose UNDROP when an object has been removed entirely with DROP and the parent still exists. Choose neither when the retention window has elapsed:
- at that point only Fail-safe (for permanent tables on Enterprise edition or higher) and only Snowflake Support can recover the data,
- and the recovery time is measured in business days rather than seconds.
Cost framing and storage accounting
Time Travel storage is billed at the same per-byte rate as active storage, but only for the bytes of older micro-partitions that the platform is retaining within the window.
For a slowly-changing reference table, the historical footprint is small because few partitions are overwritten.
For a churning fact table, the footprint can dwarf the live table because every UPDATE produces new micro-partitions and the prior version is retained for the configured window.
The account-usage views TABLE_STORAGE_METRICS and STORAGE_USAGE break out active, Time Travel, Fail-safe, and clone-contribution bytes for inspection.
-- Inspect storage breakdown per table
SELECT table_name,
active_bytes,
time_travel_bytes,
failsafe_bytes,
retained_for_clone_bytes
FROM snowflake.account_usage.table_storage_metrics
WHERE table_catalog = 'ANALYTICS_DB'
ORDER BY time_travel_bytes DESC
LIMIT 25;
The retained_for_clone_bytes column captures storage that is held because a zero-copy clone references partitions that the source has since modified. That column links Time Travel accounting to the cloning model covered in the next section: a partition cannot be reclaimed if any live object, source or clone, still points at it.
Diagram: The Time Travel and Fail-safe retention windows
The diagram makes the queryable boundary explicit: AT, BEFORE, UNDROP, and CLONE operate inside the Time Travel window. Once a partition crosses into Fail-safe, only Snowflake Support can access it, and only on permanent tables. Once Fail-safe expires, the partition is purged from storage and no recovery path exists. ---
