A user accidentally truncated the data from a frequently-modified table. The Administrator has reviewed the query history and found the truncate statement which was run on 2021-12-12 15:00 with query ID 8e5d0ca9-005e-44e6-b858-a8f5b37c5726. Which of the following statements would allow the Administrator to create a copy of the table as it was exactly before the truncated statement was executed, so it can be checked for integrity before being inserted into the main table?
Scenario:
A TRUNCATE command was accidentally run on a frequently modified table.
Query ID and timestamp are known.
Goal: restore a copy of the table as it existed right before the problematic statement, without affecting the current table.
Why Option D is Correct:
sql
CopyEdit
CREATE TABLE RESTORE_TABLE CLONE CURRENT_TABLE
BEFORE (STATEMENT => '8e5d0ca9-005e-44e6-b858-a8f5b37c5726');
This uses Zero-Copy Cloning + Time Travel.
The BEFORE (STATEMENT => ...) clause restores the exact state of the table before the TRUNCATE ran.
Creating a clone ensures the original table remains untouched for integrity checks before merging data back.
Why Others Are Incorrect:
A . BEFORE (timestamp => '2021-12-12 00:00')
Wrong timestamp: that's 15 hours before the truncate happened. Too early; may lose needed updates.
B . SELECT * FROM CURRENT_TABLE before (statement => ...)
Syntax is invalid: SELECT can't use BEFORE (STATEMENT => ...) directly like this.
C . INSERT INTO CURRENT_TABLE SELECT * FROM CURRENT_TABLE before (statement => ...)
Same syntax issue. Also risky --- directly inserting into the original table without validating the data first.
SnowPro Administrator Reference:
Cloning with Time Travel
Time Travel with Statement ID
Tish
2 days ago