In this post we are going to cover Time Travel, cloning and recovery in Snowflake: getting deleted rows back, UNDROP and retention, Time Travel versus Fail-safe, zero-copy cloning, transient and temporary tables, and rolling back a bad deployment. These are 7 real Snowflake interview questions, asked the way they come up on a real project, and the last one is a scenario where leadership asks for our recovery plan if a whole database is corrupted or a region goes down.
Time Travel is how Snowflake keeps the old versions of your data for a while, so you can query them, clone them or undrop a dropped object. Fail-safe is a short period after that, which only Snowflake support can recover from. Clones build on the same idea: a copy that shares storage with the source. Interviewers ask about it because every real project has a bad DELETE, a dropped table or a broken release at some point, and they want to know if you can get the data back calmly, and what it costs to keep that safety net.
Part 6 of the Real Time Snowflake Interview Questions and Answers series on TechBrothersIT.
- The short answer
- Question 1: Someone ran a DELETE without a WHERE clause on a production table. How do you get the data back with Time Travel?
- Question 2: A developer dropped a table by mistake an hour ago. How do UNDROP and the retention period work?
- Question 3: The auditor asks how long you can go back in time. What is the difference between Time Travel and Fail-safe?
- Question 4: The team needs a full copy of production for testing today. How does zero-copy cloning work, and what does it cost?
- Question 5: Storage costs are high on a staging table that is rebuilt every day. When do you use transient or temporary tables?
- Question 6: A bad deployment broke a schema in production. How do you roll back with a clone and Time Travel?
- Scenario 7: Leadership asks for your recovery plan if a whole database is corrupted or a region goes down. What do you propose?
The short answer
Time Travel lets you query, clone and undrop data within the retention period: 1 day by default, up to 90 days on Enterprise for permanent objects. Fail-safe adds 7 days that only Snowflake support can recover from, for permanent tables only. Zero-copy clones share storage until data changes, transient tables skip Fail-safe, and a real recovery plan adds backups and failover groups.
Keep that in mind. Every question below is one piece of it.
Question 1: Someone ran a DELETE without a WHERE clause on a production table. How do you get the data back with Time Travel?
Good news: the deleted rows are still in Time Travel, as long as we're inside the retention period, one day by default. So act fast, and don't run more DML on that table.
Let's go through it in order.
First, find the query ID of the bad DELETE in query history.
Then query the table as it was just before it, with BEFORE(STATEMENT => ...) set to that ID. The AT clause also takes an offset in seconds, or a timestamp.
-- the table just before the bad DELETE
SELECT COUNT(*) FROM sales.orders
BEFORE(STATEMENT => '<query id>');
-- or as it was five minutes ago
SELECT COUNT(*) FROM sales.orders AT(OFFSET => -60*5);Check the row count. Then restore, in one of two ways: insert the rows back from the Time Travel query, or clone the table as it was before the statement, check it, and swap it with the damaged table.
INSERT INTO sales.orders
SELECT * FROM sales.orders
BEFORE(STATEMENT => '<query id>');
-- or: clone it as it was, check it, swap it in
CREATE TABLE sales.orders_fix CLONE sales.orders
BEFORE(STATEMENT => '<query id>') COPY GRANTS;
ALTER TABLE sales.orders SWAP WITH sales.orders_fix;Now the catch: the data must still be in Time Travel. If retention on that table was set to zero, it's gone for you, and only Snowflake support can try Fail-safe, for permanent tables.
Critical tables get a longer retention, up to ninety days on Enterprise, and only a few people can run DELETE on production.
Question 2: A developer dropped a table by mistake an hour ago. How do UNDROP and the retention period work?
A dropped table isn't deleted right away. Snowflake keeps it in Time Travel for the table's retention period, so an hour ago is easy: run UNDROP TABLE, and it comes back with its data.
UNDROP works for more than tables:
- Tables, schemas and databases
- Dynamic tables and Iceberg tables
- Tags, and more
Now the catch. UNDROP fails if an object with that name already exists, usually because someone already recreated the table. Rename the new one first, then undrop the old one:
DROP TABLE sales.orders; -- by mistake
UNDROP TABLE sales.orders; -- back, with its data
-- name taken? rename the new table first
ALTER TABLE sales.orders RENAME TO sales.orders_new;
UNDROP TABLE sales.orders;
ALTER TABLE sales.orders
SET DATA_RETENTION_TIME_IN_DAYS = 30;Retention is the DATA_RETENTION_TIME_IN_DAYS parameter. Let's look at where it is set and what each edition allows:
| DATA_RETENTION_TIME_IN_DAYS | |
|---|---|
| SET ON | account, database, schema or table |
| STANDARD EDITION | 0 or 1 day |
| ENTERPRISE AND HIGHER | 0 to 90 days for permanent objects |
One more detail: a dropped object keeps the retention it had.
A temporary table with the same name as the permanent one. Inside that session the temporary table wins, so DROP and UNDROP hit the wrong table.
Question 3: The auditor asks how long you can go back in time. What is the difference between Time Travel and Fail-safe?
Time Travel is self-service. Fail-safe is a fixed seven days after it that only Snowflake can recover from.
Let's start with Time Travel. You query, clone and undrop data yourself, within the retention period: one day by default, at most one day on Standard, and up to ninety days on Enterprise and higher for permanent objects.
Then Fail-safe starts when Time Travel ends. It's a fixed seven days, you can't configure it, and you can't query it. Only Snowflake can recover data from it, through a support case. It's for disasters, not daily mistakes.
Fail-safe covers permanent tables only. Transient and temporary tables have no Fail-safe at all, and zero or one day of Time Travel.
| Time Travel | Fail-safe | |
|---|---|---|
| WHO | you: AT, BEFORE, CLONE, UNDROP | Snowflake support only |
| HOW LONG | 0 or 1 day Standard, up to 90 Enterprise | 7 days, not configurable |
| TABLES | all; transient and temporary 0 or 1 day | permanent only |
| COST | storage | storage |
So for a permanent table on Enterprise with ninety days of retention, the honest answer to the auditor is: ninety days self-service, plus seven days that only Snowflake support can try to recover.
Both cost storage, and you can see Fail-safe storage in Snowsight's cost management pages.
Lowering the retention doesn't make old data vanish. It moves into Fail-safe.
Question 4: The team needs a full copy of production for testing today. How does zero-copy cloning work, and what does it cost?
A clone is a metadata-only copy. CREATE DATABASE test_db CLONE prod_db is fast, because no data is copied. The clone points to the same micro-partitions as the source.
Now the cost. At first, almost nothing. Storage is charged only for changes: when either side updates or deletes data, the changed micro-partitions become new storage. Queries on the clone use your warehouse.
You can also clone as of a point in time, with AT or BEFORE. That fails if a child table is past its retention, unless you add IGNORE TABLES WITH INSUFFICIENT DATA RETENTION:
CREATE DATABASE test_db CLONE prod_db;
-- production as it was at a point in time
CREATE DATABASE test_db_1022 CLONE prod_db
AT(TIMESTAMP => '2026-10-22 18:00:00'::TIMESTAMP_LTZ)
IGNORE TABLES WITH INSUFFICIENT DATA RETENTION;Then check what the clone does and doesn't carry over:
- Tasks: start suspended.
- Unconsumed stream records: not accessible in the clone.
- Internal named stages: cloned only with
INCLUDE INTERNAL STAGES. - Grants: kept on child objects, but not the grants on the database itself.
Pipes on external stages are cloned too, and a pipe with a fully qualified table name in its COPY can load into production. Check the pipes right after cloning.
Question 5: Storage costs are high on a staging table that is rebuilt every day. When do you use transient or temporary tables?
Make it transient. A permanent table keeps Time Travel and then seven days of Fail-safe for the data it replaces. For a staging table rebuilt every day, that's wasted storage, because you can rebuild it from the source.
Let's compare the three table types:
| Lifetime | Time Travel | Fail-safe | |
|---|---|---|---|
| PERMANENT | until dropped | Standard 0 or 1, Enterprise up to 90 days | 7 days |
| TRANSIENT | until dropped | 0 or 1 day | none |
| TEMPORARY | rest of the session | 0 or 1 day | none |
A transient table lives until you drop it, like a permanent one, but it has no Fail-safe, and zero or one day of Time Travel. Set retention to zero if you don't even need that. Then there is no Time Travel either.
A temporary table lives only for your session, is visible only to that session, and also has no Fail-safe. Use it for scratch work inside one job or stored procedure.
You can also create a transient database or schema: schemas in a transient database are transient, and so are tables in a transient schema.
CREATE TRANSIENT SCHEMA stage; -- its tables: transient
CREATE TRANSIENT TABLE stage.orders_daily (
order_id NUMBER, status VARCHAR, amount NUMBER(10,2))
DATA_RETENTION_TIME_IN_DAYS = 0;
CREATE TEMPORARY TABLE tmp_orders AS
SELECT * FROM stage.orders_daily WHERE amount > 0;Transient only for data you can rebuild, never for your only copy of anything. Once Time Travel is over, there's no Fail-safe to fall back on.
Question 6: A bad deployment broke a schema in production. How do you roll back with a clone and Time Travel?
Let's say the release ran at 10:00 and broke the schema. Inside the retention period, every object still has its old version in Time Travel, so we can go back to 09:59.
First, find the time just before the deployment started, from the deployment log or query history.
Then clone the schema as it was at that time, with CLONE and AT(TIMESTAMP => ...). It's metadata only, so it's fast, and you can check the copy side by side: row counts, key queries, views.
If it looks right, swap it in with ALTER SCHEMA ... SWAP WITH. The clone takes the production name, and the broken schema stays under the other name for the investigation.
CREATE SCHEMA sales_fix CLONE sales
AT(TIMESTAMP => '2026-10-23 09:59:00'::TIMESTAMP_LTZ);
-- checked? swap it in, keep the broken one
ALTER SCHEMA sales SWAP WITH sales_fix;
-- schema-level grants are not cloned
GRANT USAGE ON SCHEMA sales TO ROLE reporting;
ALTER TASK sales.load_orders RESUME;Now the gotchas:
- Schema grants: re-apply them, because a schema clone keeps only the grants on the objects inside.
- Tasks: start suspended in the clone, so resume them.
- Stream records: unconsumed ones aren't accessible.
Prevention. Deploy with CREATE OR ALTER or a declarative tool, test in a clone first, and take a clone right before every release, so a rollback is one swap.
Scenario 7: Leadership asks for your recovery plan if a whole database is corrupted or a region goes down. What do you propose?
I split it into two risks, because the tools are different. Corruption is a data problem inside your account. A region outage is an infrastructure problem, and Time Travel lives in that same region.
Let's take corruption first:
- Time Travel: on critical databases, up to ninety days on Enterprise.
- Clone or UNDROP: recovery is a clone from before the damage, or undrop for a dropped database.
- Fail-safe: the last resort, through Snowflake support.
Then add backups, which are now generally available: point-in-time backups of tables, schemas or databases, using backup policies and backup sets. On Business Critical, a retention lock stops anyone from deleting them early, even an admin.
Now the region outage:
- Failover group: replicate to an account in another region.
- Business Critical: database replication works on all editions, but failover and account objects need Business Critical or higher.
- Client Redirect: keeps the same connection URL after a failover.
-- primary account: how often to refresh
ALTER FAILOVER GROUP prod_fg
SET REPLICATION_SCHEDULE = '10 MINUTE';
-- secondary account, on failover
ALTER FAILOVER GROUP prod_fg PRIMARY;Finally, agree the RPO and RTO with the business, schedule the replication refresh to meet them, and run a failover drill.
A plan nobody has tested isn't a plan.
Key points to remember
- Time Travel: AT, BEFORE, UNDROP; 1 day default, up to 90 on Enterprise
- Fail-safe: 7 fixed days, Snowflake support only, permanent tables
- Zero-copy clone: metadata only, pay for changed storage
- Transient tables: no Fail-safe, for data you can rebuild
- Recovery plan: backups, failover groups, Client Redirect, drills
Part 7: Semi-Structured Data and Iceberg Tables
Part of the Real Time Snowflake Interview Questions and Answers series on TechBrothersIT. Features, limits and their status (GA or preview) are current as of October 2026; check the Snowflake documentation for anything you quote in an interview.



No comments:
Post a Comment
Note: Only a member of this blog may post a comment.