Skip to main content

News

Data protection and fail safe in snowflake

An Analyst Uses A Computer And Dashboard For Data Business Analysis And Data Management System With Kpi And Metrics Connected To The Database For Technology Finance, Operations, Sales, Marketing

Problem statement: It is not uncommon to accidentally execute statements that update or delete incorrect data in database tables. To address this, Snowflake offers a feature known as Fail-safe, which allows for the recovery of lost or altered data. This functionality provides a way to restore data that may have been mistakenly updated or deleted. Below, we outline several examples and methods for recovering data using Snowflake’s Fail-safe feature.

Snowflake Time Travel is a powerful feature that allows users to access historical data — including data that has been modified or deleted — at any point within a specified retention period. This functionality is essential for a variety of tasks, including:

  • Restoring deleted data objects: Recover tables, schemas, and databases that may have been accidentally or intentionally deleted.
  • Backing up and duplicating data: Capture and preserve data from key moments in the past for reference or archiving purposes.
  • Analyzing data changes: Examine how data has been used or manipulated over specific time periods.

With Snowflake Time Travel, users can perform the following actions within the defined retention window:

Below is the table created in snowflake

File1

Below is the statement used to update ‘GENDER’ column to F accidentally for all the records.

File2

Below is the statement which is used to recover data before 1 minute.

Select * from employees at(offset =>-60*1 );

File3

The other way that we can use to recover the data is using query id. As below mentioned go to the monitoring section and get the query id’s and execute the below select statement.

File4

Select * from stg.employees before (statement => ’01b84ac0-0712-2262-0074-35030a0b41ce’);

 

Below are the 2 statements used to recover the dropped table.

Drop table table_name;

 

File5

Undrop table table_name;

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Premchand Kosaraju

Premchand Kosaraju works at Perficient as Lead Technical Consultant. He has a firm understanding on technologies like Informatica PowerCenter, Informatica Cloud & Talend Data Integration. He is keen to learn new technologies.

More from this Author

Categories
Follow Us