Module 14 · Lesson 2 of 12Detailed study · about 22 min

Configure retention before you need recovery

DATA_RETENTION_TIME_IN_DAYS controls the historical recovery window, subject to object type, edition and account policy.

Your learning goal

Inspect effective retention, choose a defensible recovery window and explain the distinction between parent defaults and a child’s retained data.

Understand the idea

A concrete example

If an overnight job corrupts orders and nobody notices for two days, a one-day Time Travel policy is insufficient. Detection delay is part of the recovery design.

Key ideas in simple English
ConceptWhat it means
Permanent · Standard0 or 1 day; the usual default is 1.
Permanent · Enterprise+Configurable up to 90 days.
Transient / temporary0 or 1 day; no Fail-safe. Temporary data is session-scoped.
Account minimumCan raise effective permanent-table retention; inspect policy as well as the table setting.

Remember: Inspect critical table settings and detection delays together. Document who may reduce retention.

Explain it step by step · full theory

Learning objectives and prerequisites

Inspect effective retention, choose a defensible recovery window and explain the distinction between parent defaults and a child’s retained data.

Build on Modules 02–04: storage, table types, SELECT, DML and transactions. Module 13 explains why recovery must preserve valid business history. Use the first lesson’s isolated setup; examples name separate demonstration tables so the baseline ORDERS stays unchanged.

A window for changed data, not an expiry date for active rows

A table with one-day retention does not lose all current rows after a day. The setting determines how long prior data remains eligible after changes. An unchanged live order can remain in the table indefinitely.

Longer retention gives investigators more time, but changed historical data can consume more storage. Select a window based on detection delay, investigation time and recovery obligations, not simply the largest supported value.

Inheritance and explicit overrides

Account, database and schema settings supply defaults to lower levels. A table can have its own explicit override. Changing a parent does not mean every child has the same effective policy; inspect each critical child. A historical schema clone can fail when one table has already lost the required data.

MIN_DATA_RETENTION_TIME_IN_DAYS is an administrator-controlled account floor for permanent tables. It does not apply to temporary or transient tables. Inspect this account policy when a permanent-table setting of zero appears not to disable retention. Stream-related retention extension can also keep source history longer; it is not a substitute for a recovery policy.

Why increasing retention is not retroactive resurrection

Suppose an old version already left Time Travel. Raising the table from one day to seven days cannot make that missing version queryable again. It can extend protection for data that is still eligible. Lowering retention can shorten the recovery opportunity, so treat it as a controlled change.

A parent’s seven-day setting does not grant seven-day history to a child explicitly configured for one day. Confirm actual object settings before promising a recovery point.

Choose object type from recoverability

Permanent tables suit important orders when no easy rebuild exists. Transient tables can suit reconstructible intermediate data. Temporary tables are private to their session and should not store the only evidence needed after the session ends.

The lab uses ordinary Snowflake-managed permanent tables with one-day retention. Hybrid, external and Iceberg tables have separate capabilities; do not transfer this matrix to every table technology.

Recovery policy for the learning scenario
ObjectReasonable choiceTrade-off
Authoritative ordersPermanent with justified retentionHistorical and Fail-safe storage
Rebuildable QA intermediateTransient if loss is acceptableNo Fail-safe; short history
Single-session calculationTemporaryNot a durable recovery source

Production decisions and common mistakes

Inspect critical table settings and detection delays together. Document who may reduce retention.

Do not set retention to zero during an incident to save storage, or increase it afterwards expecting expired data to return.

Key takeaways

The time between a bad change and its discovery may exceed a day. Improve monitoring, choose an eligible longer policy where available, and design independent recovery sources for obligations beyond Time Travel.

Words used in this lesson
Retention
The eligibility window for historical recovery.
Inheritance
A lower-level object uses an applicable parent default unless overridden.
Permanent
A table type with Time Travel and Fail-safe protection.
Transient
A persistent table type without Fail-safe.

See how it works

Choose a step to explore the idea at your own pace.

Open the interactive explanation
Interactive explainer1 / 3

Configure retention before you need recovery

Before change
  • A
  • B
Historical / retained
Current references
  • A
  • B2
Current / planned state

A change creates history

Imagine immutable blocks A and B. An update produces replacement block B2. Actual partition layouts are managed by Snowflake; a single changed row does not imply a single new block.

Automatic playback is off for reduced motion. Select any step or use Previous and Next. Illustrations explain behavior; they are not live measurements.

Read the complete diagram explanation
  1. A change creates history

    Imagine immutable blocks A and B. An update produces replacement block B2. Actual partition layouts are managed by Snowflake; a single changed row does not imply a single new block.

    • Before change: A; B
    • Current references: A; B2
  2. Retention protects the old version

    An eligible historical query can still reference B. The old version’s retention window begins with its change, not the date the table was created.

    • Current: A + B2
    • Time Travel: B retained until eligible window ends
  3. Settings do not recreate expired data

    Increasing retention protects data still available; it cannot pull an expired version back into Time Travel. A parent default also cannot repair a child’s already expired history.

    • Increase retention: Keep eligible versions longer
    • Already expired: Not revived

Try the SQL or command

Read → predict → run in your learning environment → compare. You can also learn by reading without an account.

New to SQL? Where to run it and how to read it

A query is a question written in SQL. Snowflake runs it and returns a result table. This website shows examples; it does not connect to your account.

  1. No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
  2. For SQL practice, use a learning account in Snowsight and select an authorized role and warehouse. A role determines permissions; a warehouse supplies processing power. Follow the example’s database/schema setup when it refers to stored objects.
  3. Read the entire example, including comments beginning with --. Run the selected statement or labeled block in the stated order. Examples labeled Python, shell or HTTP belong in that client, not in a SQL editor.
  4. Compare values and row counts with the explained result. If an example deliberately causes an error, follow its rollback and cleanup steps before continuing.
SELECT / FROM
Choose the values to return / identify their input.
VALUES / COLUMN1
VALUES supplies tiny example rows. COLUMN1 means their first column, COLUMN2 their second.
AS / WITH
AS gives a result a readable name. WITH names a temporary query step within one statement.
NULL / ::
NULL means missing or unknown. The :: notation converts a value to a named data type.
Session
One connection and its settings. Keep related transaction steps in the same session.
Database.schema.table
A full address for stored data. It is separate from the warehouse that processes queries.

Need the L2_OBJECTS_LAB setup? Open the first database-object lesson →

Help with common practice errors
  • No active warehouse: select a warehouse your role can use. Do not assume you need to create a new one.
  • Object missing or not authorized: check the full name, required setup and active role. Ask the account owner for access if needed.
  • Object already exists: setup may already have run. Read the current state or choose a fresh lab name consistently; do not add OR REPLACE blindly.
  • Different result: check whether an earlier INSERT or UPDATE changed the data. VALUES examples provide their own fresh input for each statement.

Before running this lesson

Manual Snowflake practice only; SQL has not been executed for this course. Use an authorized warehouse and role with access to L2_OBJECTS_LAB and CREATE SCHEMA/CREATE TABLE as needed. Run in M14_LAB, in one session with one writer, using autocommit unless a transaction is shown. Run CREATE once, never replace an existing production object. Standard Edition with one-day retention is sufficient for the main lab; longer retention and administrative monitoring have separate requirements.

Inspect and set the lab policy

Definition: SHOW PARAMETERS reveals the configured value and its source level.

When to use: Before simulating loss.

SQL · example
USE SCHEMA L2_OBJECTS_LAB.M14_LAB;
SHOW PARAMETERS LIKE 'DATA_RETENTION_TIME_IN_DAYS' IN TABLE ORDERS;
SHOW PARAMETERS LIKE 'MIN_DATA_RETENTION_TIME_IN_DAYS' IN ACCOUNT;
ALTER TABLE ORDERS SET DATA_RETENTION_TIME_IN_DAYS=1;

What to expect and why

The explicit table value becomes 1. Account policies and stream-related extensions may retain data longer. If account visibility is restricted, ask the administrator rather than changing account policy.

Defaults and an optional longer window

Definition: The same parameter is supported on database, schema and table objects.

When to use: Only change a dedicated learning database that you own.

SQL · example
-- Examples for an authorized learning environment only:
ALTER SCHEMA L2_OBJECTS_LAB.M14_LAB SET DATA_RETENTION_TIME_IN_DAYS=1;
-- Optional if this entire database is yours to administer:
-- ALTER DATABASE L2_OBJECTS_LAB SET DATA_RETENTION_TIME_IN_DAYS=1;
-- Enterprise or higher, only if approved:
-- ALTER TABLE L2_OBJECTS_LAB.M14_LAB.ORDERS SET DATA_RETENTION_TIME_IN_DAYS=7;
-- Account defaults/floors require administrator review, not this lab.
SHOW TABLES LIKE 'ORDERS' IN SCHEMA L2_OBJECTS_LAB.M14_LAB;

What to expect and why

Do not uncomment a seven-day setting on Standard Edition. A successful ALTER changes policy, not the amount of historical data already available.

Check your understanding

Choose an answer, then check your reasoning. This is practice, not a scored test.

A table’s historical data expired yesterday. Will increasing retention today restore it?

Try it yourself

A daily report is reviewed only each Monday. Explain why a one-day window could be risky.

Compare your reasoning

The time between a bad change and its discovery may exceed a day. Improve monitoring, choose an eligible longer policy where available, and design independent recovery sources for obligations beyond Time Travel.

Key takeaway

Inspect critical table settings and detection delays together. Document who may reduce retention.

Connect this lesson to the learning path

Official sources and curriculum

Module 14 · See module scope

By Rohit Ray · Independent educational lesson · Explore this visual lab