CertSafari
    Snowflake SnowPro Advanced: Data Engineer (DEA-C02)· Lessons

    Domain 3 · Lesson 11/22

    Time Travel, UNDROP and Fail-safe in Snowflake

    Implement and manage data recovery features in Snowflake.

    18 min read
    4.67% of exam
    12 sources
    Published 20 Oct 2026
    Docs as of 18 Oct 2026

    What you will be able to do

    • Set and inherit DATA_RETENTION_TIME_IN_DAYS within the limits of each edition and table type
    • Query a table's past state with AT | BEFORE using a timestamp, an offset or a statement ID
    • Restore a dropped table, schema or database with UNDROP and resolve a name conflict
    • Explain what Fail-safe can and cannot do, and which tables have none
    • Explain how streams extend a table's retention and when they go stale
    • Plan replication across regions and cloud platforms, including the region-group, edition and object limits that apply

    Key concept

    Data retention period — The number of days Snowflake keeps the earlier versions of changed or dropped data so that you can query, clone or restore them yourself. Each change gets its own window, and when the window closes that version moves to Fail-safe, where only Snowflake can reach it.

    1.Retention periods, editions and inheritance

    Time Travel lets you reach data that has since been changed or deleted. You can query it, clone it, or restore an object that was dropped, as long as you stay inside a fixed window called the data retention period. Nothing has to be switched on: every account starts with a 1-day retention period.

    Your edition decides how long that window can be. On Standard Edition, any object's retention is either the 1-day default or 0. On Enterprise Edition and higher, permanent databases, schemas and tables accept any value from 0 to 90 days. Transient and temporary objects stay at 0 or 1 day on every edition. A longer window costs money, because the extra history is billed as storage.

    Time Travel and Fail-safe periods by table type and edition
    Table typeTime Travel retention (days)Fail-safe (days)
    Temporary0 or 1 (default is 1)0
    Transient0 or 1 (default is 1)0
    Permanent (Standard Edition)0 or 1 (default is 1)7
    Permanent (Enterprise Edition and higher)0 to 90 (default is configurable)7

    The DATA_RETENTION_TIME_IN_DAYS parameter sets the window. A user with ACCOUNTADMIN sets the account default. Any database, schema or table can override it when it is created or at any time afterwards. A value set on a database or schema becomes the default for every object created inside it. Setting 0 on an object turns Time Travel off for that object. You cannot turn Time Travel off for the whole account: an account-level 0 only changes the default that new databases start with, and each one can still override it.

    MIN_DATA_RETENTION_TIME_IN_DAYS puts a floor under all of this. An ACCOUNTADMIN sets it at the account level. It does not change any object's DATA_RETENTION_TIME_IN_DAYS. Instead, Snowflake uses whichever of the two values is larger. A table set to 0 in an account with a minimum of 7 still keeps 7 days of history.

    Each piece of history gets its own window, and that window starts when the data changes. In the example above, the old version of the row can be queried until Day 6 at 1:00 PM. After that it spends 7 days in Fail-safe. To see the retention that actually applies to an object, read the retention_time column from SHOW TABLES, SHOW SCHEMAS or SHOW DATABASES. Add the HISTORY keyword to include objects that have already been dropped.

    Checking the retention period of specific tables by filtering SHOW outputsql
    SHOW TABLES
      ->> SELECT "name", "retention_time"
            FROM $1
            WHERE "name" IN ('MY_TABLE1', 'MY_TABLE2');

    Checkpoint 1 of 9· Check yourself

    In an Enterprise Edition account, an ACCOUNTADMIN has set MIN_DATA_RETENTION_TIME_IN_DAYS = 7. A developer sets DATA_RETENTION_TIME_IN_DAYS = 0 on a permanent table and then updates rows in it. Three days later, can the developer use Time Travel to query the rows as they were before the update?

    Checkpoint 2 of 9· Fill the gap

    You want to see the retention period that actually applies to two tables. Which column completes this query?

    SHOW TABLES
      ->> SELECT "name", " ? "
            FROM $1
            WHERE "name" IN ('MY_TABLE1', 'MY_TABLE2');

    Checkpoint 3 of 9· Exam question

    Which statement correctly describes how Time Travel retention periods differ across Snowflake editions for permanent tables?

    Sources1

    2.Querying past states with AT and BEFORE

    To read the past, add a clause to the table reference. Put AT | BEFORE right after the object name in a SELECT or in a CREATE … CLONE. It takes one of three parameters to identify the moment you want:

    • TIMESTAMP: a specific point in time.
    • OFFSET: a difference in seconds from now, so -60*30 means thirty minutes ago.
    • STATEMENT: the query ID of a statement.

    Here is a typical case. Thirty minutes ago, an engineer ran a DELETE that emptied orders, and the table keeps 3 days of history. Querying it with AT(OFFSET => -60*30), or with STATEMENT and the DELETE's query ID, returns the rows as they were before the delete. With BEFORE(STATEMENT => ...), the point used is just before that statement completed, not before it started. Changes that other sessions committed while the DELETE was running are therefore included. The same clause on a CREATE … CLONE copies the past state into a new object without copying storage, which is covered in Time Travel and cloning for development environments.

    Two details can catch you out with historical queries. First, Snowflake applies the table's current schema, so a column dropped since then does not come back. Second, a timestamp is read in the session's time zone. In a session set to UTC, a literal cast to plain TIMESTAMP can land before the table existed, and the query fails. Casting to TIMESTAMP_LTZ fixes it.

    Querying a table at a past timestamp, cast to the local time zonesql
    SELECT * FROM tt1 at(TIMESTAMP => '2024-06-05 15:29:00'::TIMESTAMP_LTZ);

    Checkpoint 4 of 9· Check yourself

    Two hours ago, an UPDATE on the permanent table products overwrote every price with the wrong value. The table keeps 1 day of history, and you have the UPDATE's query ID. Which statement gets you a copy of the table with the correct prices?

    Checkpoint 5 of 9· Exam question

    A data engineer accidentally truncates a critical orders table with a DELETE statement thirty minutes ago and needs to recover the pre-delete rows immediately. The table's DATA_RETENTION_TIME_IN_DAYS is set to 3. Which approach lets the engineer query the table exactly as it existed before the DELETE ran?

    Sources12

    3.Restoring dropped objects with UNDROP

    A dropped table, schema or database is not removed right away. Snowflake keeps it for the object's retention period, and during that time UNDROP TABLE, UNDROP SCHEMA or UNDROP DATABASE puts it back exactly as it was just before the DROP. The object is restored in place rather than recreated. Restoring a schema or database brings back everything inside it. Once a dropped object has moved to Fail-safe, you can no longer undrop it. An object whose retention was 0 can never be undropped.

    The name-conflict rule is the one that catches people. If an object with the same name already exists, UNDROP fails. It does not merge the two objects, rename either one, or overwrite the newer one. Creating a new object with the old name also does not restore anything: it creates a new version, and the dropped version stays available. To get the old one back, rename the current object first and then run UNDROP. If a name was dropped several times, SHOW TABLES HISTORY lists each version with a dropped_on value, and UNDROP restores the most recent one.

    Renaming the current table so the dropped version of the same name can be restoredsql
    ALTER TABLE loaddata1 RENAME TO loaddata3; UNDROP TABLE loaddata1;

    UNDROP has requirements of its own. You need OWNERSHIP of the dropped object and the CREATE privilege for that object type in the target database or schema. Tables and schemas are restored into the current schema or database, even if you give a fully qualified name. Hybrid tables cannot be undropped.

    Checkpoint 6 of 9· Exam question

    An analyst runs DROP SCHEMA reporting by mistake, and five minutes later a second analyst creates a brand-new schema also named reporting in the same database. The retention period on the original schema was 3 days. What happens when someone now runs UNDROP SCHEMA reporting?

    Sources13

    4.Fail-safe: seven days that only Snowflake can use

    Fail-safe begins as soon as an object's Time Travel window ends, and it always lasts 7 days. You cannot change that period, and you cannot query it. It exists so that Snowflake can recover data after extreme operational failures. It is not a way to extend your own access to history. To use it, you open a case with Snowflake Support. Recovery is best-effort, can take from several hours to several days, and runs on Snowflake-managed serverless compute that is billed to you. To find those charges, filter the metering history views for the FAILSAFE_RECOVERY service type.

    Not every table has Fail-safe. Transient and temporary tables have a Fail-safe period of 0. Once their retention ends, the history is deleted instead of being kept. That is the point of using them for staging data you can reload, because they never pay for 7 days of Fail-safe storage. Permanent tables always get 7 days. Tables that contain data loaded with the classic Snowpipe Streaming architecture cannot be recovered from Fail-safe at all.

    One timing detail matters: a long-running Time Travel query holds up the move of data and objects in the account into Fail-safe until the query finishes. If you are an ACCOUNTADMIN, you can see Fail-safe storage in Snowsight's consumption view under the Storage usage type.

    Checkpoint 7 of 9· Match them up

    Who can recover lost data, and how, depends on where that data now sits. Match each recovery path or situation to what it actually gives you.

    Tap a term, then the definition that fits it.

    Sources41

    5.Impact of streams on retention

    A stream records the row-level changes made to a source table since its offset. This is described in Streams (change data capture). A stream does not store any data itself. It stores an offset and reads changes from the table's version history, so it can only work while that history still exists. This is why a stream can stretch the source table's retention period.

    Snowflake protects unconsumed streams automatically. If a source table's DATA_RETENTION_TIME_IN_DAYS is under 14 days and a stream on it has not been consumed, Snowflake temporarily extends retention back to the stream's offset. By default the extension can reach 14 days, on any edition. MAX_DATA_EXTENSION_TIME_IN_DAYS sets that limit and can be set on the account, database, schema or table. A value of 0 turns the extension off. Once the limit passes and the stream still has not been consumed, the stream goes stale.

    For example, a table with 1-day retention whose stream is read by a weekly job works, because the extension covers the gap. The same job breaks if someone sets MAX_DATA_EXTENSION_TIME_IN_DAYS = 0 on the table to save storage. To catch this before it happens, check the stale_after column of SHOW STREAMS.

    Checkpoint 8 of 9· Check yourself

    A data engineer wants to cut storage costs on orders. A stream on that table is read by a weekly job. Before changing any retention settings, the engineer asks where the stream gets the change records it returns. Which answer is correct?

    Sources561

    6.Replicating across regions and cloud platforms

    A copy of your data in another region, or on another cloud, is what keeps it reachable when a whole region or provider goes down. Time Travel and Fail-safe history never leaves the account that owns it, so surviving that kind of outage depends on replicating objects to a second account in the same organization. Replication works across regions and across cloud platforms. Every Snowflake region on Amazon Web Services, Google Cloud Platform and Microsoft Azure supports it, so a primary on AWS in Europe can feed a secondary on Azure in North America.

    Region groups are the one boundary. Any region can replicate to any other region in the same region group with no extra step. Crossing groups, for example from a commercial region to a government or Virtual Private Snowflake region, needs a request to Snowflake Support.

    Your edition decides what can make the trip. Database and share replication work on every edition, so even a Standard account can keep a cross-cloud copy of its databases. Failover groups, and replication of account objects such as users, roles and warehouses, need Business Critical Edition or higher. Sending a Business Critical database to an account on a lower edition returns an error unless an account administrator adds IGNORE EDITION CHECK to ALTER DATABASE … ENABLE REPLICATION TO ACCOUNTS.

    Some objects do not survive every crossing. Iceberg tables that use Snowflake storage are skipped during refresh when the target account is hosted on Google Cloud, so a GCP failover target comes up without them. Replicated Iceberg tables on an external volume need a storage location configured in the same region as the target account.

    Churn, not distance, drives the bill. When rows are updated or deleted, every affected micro-partition is re-created and has to be synchronized to each secondary, so a large dimension table rewritten every night can cost more to replicate than a much bigger append-only fact table. Refreshing the database that holds it less often, or remodelling to reduce churn, brings that cost down.

    Every refresh is checked automatically. Snowflake compares the hash of each replicated file and, for each table, the file, row and byte counts; on any mismatch the refresh fails. For an audit of your own, run HASH_AGG on a table in the secondary, then run it on the primary with an AT TIMESTAMP clause set to the refresh's snapshot timestamp. Time Travel on the primary is what lets the two results be compared at all.

    Checkpoint 9 of 9· Check yourself

    A Business Critical account on AWS adds a target account hosted on Google Cloud to a failover group. The replicated database holds permanent tables and Iceberg tables that use Snowflake storage. After the first refresh, what is in the target account?

    Sources78910

    Sources

    (12)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “For permanent databases, schemas, and tables, the retention period can be set to any value from 0 up to 90 days.”
      ↩︎ Retention periods, editions and inheritance
      “If a retention period is specified for a database or schema, the period is inherited by default for all objects created in the database/schema.”
      ↩︎ Retention periods, editions and inheritance
      “Time Travel cannot be deactivated for an account.”
      ↩︎ Retention periods, editions and inheritance
      “extended data retention requires additional storage which will be reflected in your monthly storage charges”
      ↩︎ Retention periods, editions and inheritance
      “OFFSET (time difference in seconds from the present time)”
      ↩︎ Querying past states with AT and BEFORE
      “When querying historical data in a table or non-materialized view, the current table or view schema is used.”
      ↩︎ Querying past states with AT and BEFORE
      “You must rename the existing object, which then enables you to restore the previous version of the object.”
      ↩︎ Restoring dropped objects with UNDROP
      “After dropping an object, creating an object with the same name does not restore the object.”
      ↩︎ Restoring dropped objects with UNDROP
      “Restoring tables and schemas is only supported in the current schema or current database, even if a fully-qualified object name is specified.”
      ↩︎ Restoring dropped objects with UNDROP
      “Once dropped objects are moved to Fail-safe, you cannot restore them.”
      ↩︎ Restoring dropped objects with UNDROP
      “any modified or deleted data is moved into Fail-safe (for permanent tables) or deleted (for transient tables) by a background process.”
      ↩︎ Fail-safe: seven days that only Snowflake can use
      “For streams, you can check the value of the stale_after column in the output from the SHOW STREAMS command.”
      ↩︎ Impact of streams on retention
      “The data retention period specifies the number of days for which this historical data is preserved”
      ↩︎ Key concept
      “the effective minimum data retention period for an object is determined by MAX(DATA_RETENTION_TIME_IN_DAYS, MIN_DATA_RETENTION_TIME_IN_DAYS).”
      ↩︎ Exam trap 1
      “If an object with the same name already exists, UNDROP fails.”
      ↩︎ Exam trap 2
      “End of Time Travel = time of the change + data retention period”
      ↩︎ Prediction
      “the data retention period for an object is determined by MAX(DATA_RETENTION_TIME_IN_DAYS, MIN_DATA_RETENTION_TIME_IN_DAYS).”
      ↩︎ Checkpoint
      “AT | BEFORE clause which can be specified in SELECT statements and CREATE … CLONE commands (immediately after the object name).”
      ↩︎ Checkpoint
    2. 2.
      “just before the statement for that query ID is completed rather than before the statement is started”
      ↩︎ Querying past states with AT and BEFORE
      “The query fails because the time zone of the session is UTC, and the explicit cast to TIMESTAMP honors that time zone.”
      ↩︎ Querying past states with AT and BEFORE
    3. 4.
      “Fail-safe provides a (non-configurable) 7-day period during which historical data may be recoverable by Snowflake.”
      ↩︎ Fail-safe: seven days that only Snowflake can use
      “Data recovery through Fail-safe may take from several hours to several days to complete.”
      ↩︎ Fail-safe: seven days that only Snowflake can use
      “It is for use only by Snowflake to recover data that may have been lost or damaged due to extreme operational failures.”
      ↩︎ Exam trap 3
    4. 5.
      “Maximum number of days Snowflake can extend the data retention period for tables to prevent streams on the tables from becoming stale.”
      ↩︎ Impact of streams on retention
      “A value of 0 effectively disables the automatic extension for the specified database, schema, or table.”
      ↩︎ Impact of streams on retention
    5. 6.
      “A stream only stores an offset for the source object and returns CDC records by leveraging the versioning history for the source object.”
      ↩︎ Impact of streams on retention
    6. 7.
      “Replication is supported across regions and across cloud platforms.”
      ↩︎ Replicating across regions and cloud platforms
      “All Snowflake regions across Amazon Web Services, Google Cloud Platform, and Microsoft Azure support replication.”
      ↩︎ Replicating across regions and cloud platforms
      “Customers can replicate across all regions within a region group.”
      ↩︎ Replicating across regions and cloud platforms
      “Database replication and share replication are available on all editions.”
      ↩︎ Replicating across regions and cloud platforms
      “Failover group replication requires Business Critical Edition or higher.”
      ↩︎ Replicating across regions and cloud platforms
      “Replication is supported across regions and across cloud platforms.”
      ↩︎ Exam trap 4
    7. 8.
      “If IGNORE EDITION CHECK is set, the primary database can be replicated to the specified accounts on any Snowflake edition.”
      ↩︎ Replicating across regions and cloud platforms
    8. 9.
      “For replicated tables, you must configure access to a storage location in the same region as the target account.”
      ↩︎ Replicating across regions and cloud platforms
      “For large, high-churn dimension tables, the replication costs can be significant.”
      ↩︎ Replicating across regions and cloud platforms

    Also cited

    Continue to part 2 of 2

    Cross-region and cross-cloud replication and failover in Snowflake

    Spotted a mistake, or was something unclear? Tell us.