Snowflake SQL cheat sheet
Time Travel, streams, tasks, warehouses, and VARIANT — one printable page.
Time Travel and clones
select * from t at (offset => -3600);- Query t as it was 1 hour ago.
undrop table t;- Restore a dropped table inside the retention window.
create table t2 clone t at (timestamp => ...)- Zero-copy clone from a point in time.
alter table t set data_retention_time_in_days = 7;- Enterprise: 0–90 days. Storage is not free.
Streams and Tasks
create stream s on table t;- CDC change table for inserts/updates/deletes.
create task my_task warehouse = wh schedule = '5 minute' as ...- Serverless or warehouse-backed scheduler.
alter task my_task resume;- Tasks start suspended. Always resume after create.
Warehouses
alter warehouse wh set auto_suspend = 60 auto_resume = true;- Default 10 minutes burns idle credits.
alter warehouse wh set warehouse_size = 'MEDIUM';- Each size doubles credits/hour. Test one size down.
Semi-structured
select rec:id::string, f.value:sku::string from t, lateral flatten(input => rec:items) f;- VARIANT + FLATTEN for JSON arrays.
From DataLane — tutorials at/blog, practice SQL live in theplayground.