0
0
Snowflakecloud~20 mins

Querying historical data (AT, BEFORE) in Snowflake - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Snowflake Time Travel Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
Querying data at a specific point in time
You want to query the state of a table named orders exactly as it was at the timestamp '2024-01-01 12:00:00'. Which SQL query will return the correct historical data snapshot in Snowflake?
ASELECT * FROM orders BEFORE (TIMESTAMP => '2024-01-01 12:00:00');
BSELECT * FROM orders AT (OFFSET => '2024-01-01 12:00:00');
CSELECT * FROM orders AT (TIMESTAMP => '2024-01-01 12:00:00');
DSELECT * FROM orders FOR SYSTEM_TIME AS OF '2024-01-01 12:00:00';
Attempts:
2 left
💡 Hint
Use the Snowflake syntax that queries the table state exactly at a given timestamp.
service_behavior
intermediate
2:00remaining
Querying data before a specific timestamp
You want to retrieve all rows from the customers table as they existed strictly before '2024-03-15 08:00:00'. Which query will correctly return this data in Snowflake?
ASELECT * FROM customers BEFORE (TIMESTAMP => '2024-03-15 08:00:00');
BSELECT * FROM customers AT (TIMESTAMP => '2024-03-15 08:00:00');
CSELECT * FROM customers WHERE created_at < '2024-03-15 08:00:00';
DSELECT * FROM customers FOR SYSTEM_TIME BEFORE '2024-03-15 08:00:00';
Attempts:
2 left
💡 Hint
Use the Snowflake clause that returns data before a given timestamp.
🧠 Conceptual
advanced
1:30remaining
Understanding Snowflake Time Travel retention
What is the default maximum time travel retention period for standard Snowflake accounts, during which historical data can be queried using AT or BEFORE clauses?
A90 days
B30 days
C7 days
D1 day
Attempts:
2 left
💡 Hint
Think about how long Snowflake keeps historical data by default for querying.
Architecture
advanced
2:30remaining
Designing a data recovery strategy using Snowflake Time Travel
You want to design a recovery plan for accidental data deletion in a Snowflake table. Which approach best uses Snowflake's time travel feature to restore data to a point before deletion?
AUse <code>ROLLBACK TRANSACTION</code> to undo the deletion immediately.
BUse <code>SELECT * FROM table AT (TIMESTAMP => ...)</code> to query historical data, then insert it back into the table.
CUse <code>RESTORE TABLE table TO BEFORE DELETE</code> command to revert the table automatically.
DUse <code>SELECT * FROM table WHERE deleted = FALSE</code> to filter out deleted rows.
Attempts:
2 left
💡 Hint
Snowflake does not have a direct restore command but allows querying past data states.
security
expert
2:00remaining
Access control for querying historical data in Snowflake
Which Snowflake privilege is required for a user to query a table's historical data using the AT or BEFORE clauses?
AUSAGE privilege on the database and schema, plus SELECT privilege on the table
BOWNERSHIP privilege on the table only
CMONITOR privilege on the account
DCREATE STAGE privilege on the schema
Attempts:
2 left
💡 Hint
Think about the privileges needed to read data from a table, including historical data.