Data Retention Period in Snowflake
When data in a table is modified, including deletion of data or dropping an object containing data, Snowflake preserves the state of the data before the update.
The data retention period specifies the number of days for which this historical data is preserved and, therefore, Time Travel operations (SELECT, CREATE … CLONE, UNDROP) can be performed on the data.
In this video , this topic is covered in-detail.
Documentation Link:
---------------------------------------
https://docs.snowflake.com/en/user-guide/data-time-travel.html#data-retention-period
Prerequisite:
-------------------------
Snowflake Time Travel
https://youtu.be/Eo4WSnQTwb4
Undrop a Table, Database or Schema | Snowflake Interview Question
https://youtu.be/WdZfLPhltXc
Code:
-----------------
drop database ramu;
create database ramu;
CREATE TABLE RAMU.PUBLIC.hello_world as select * from SNOWFLAKE_SAMPLE_DATA.TPCH_SF10.CUSTOMER limit 1000;
select * from RAMU.PUBLIC.hello_world;
show tables like 'hello_world' in RAMU.PUBLIC;
drop table RAMU.PUBLIC.hello_world;
select * from RAMU.PUBLIC.hello_world;
undrop table RAMU.PUBLIC.hello_world;
select * from RAMU.PUBLIC.hello_world;
ALTER TABLE RAMU.PUBLIC.hello_world SET DATA_RETENTION_TIME_IN_DAYS=0;
drop table RAMU.PUBLIC.hello_world;
select * from RAMU.PUBLIC.hello_world;
undrop table RAMU.PUBLIC.hello_world;
select * from RAMU.PUBLIC.hello_world;
------------------------------------------------------------------------------------------
create or replace TABLE HELLO_WORLD1 (
C_CUSTKEY NUMBER(38,0),
C_NAME VARCHAR(25),
C_ADDRESS VARCHAR(40),
C_NATIONKEY NUMBER(38,0),
C_PHONE VARCHAR(15),
C_ACCTBAL NUMBER(12,2),
C_MKTSEGMENT VARCHAR(10),
C_COMMENT VARCHAR(117)
) data_retention_time_in_days=45;
show tables like 'HELLO_WORLD1' in RAMU.PUBLIC;
------------------------------------------------------------------------------------------------------------------------------------
--There may be a 1-2 hour delay in updating storage related statistics
SELECT * FROM "SNOWFLAKE"."ACCOUNT_USAGE"."TABLE_STORAGE_METRICS" ;
SELECT ID,TABLE_NAME,TABLE_SCHEMA,TABLE_CATALOG,ACTIVE_BYTES/(1024*1024*1024) as STORAGE_USED_GB,
TIME_TRAVEL_BYTES/(1024*1024*1024) as TIME_TRAVEL_STORAGE_USED_GB from "SNOWFLAKE"."ACCOUNT_USAGE"."TABLE_STORAGE_METRICS"
order by STORAGE_USED_GB desc , TIME_TRAVEL_STORAGE_USED_GB desc;
Check this playlist for more Data Engineering related videos:
https://youtube.com/playlist?list=PLjfRmoYoxpNopPjdACgS5XTfdjyBcuGku
Snowflake Complete Course from scratch with End-to-End Project with in-depth explanation--
https://doc.clickup.com/37466271/d/h/13qc4z-104/d4346819bd8d510
🙏🙏🙏🙏🙏🙏🙏🙏
YOU JUST NEED TO DO
3 THINGS to support my channel
LIKE
SHARE
&
SUBSCRIBE
TO MY YOUTUBE CHANNEL
Видео Data Retention Period in Snowflake канала Knowledge Amplifier
The data retention period specifies the number of days for which this historical data is preserved and, therefore, Time Travel operations (SELECT, CREATE … CLONE, UNDROP) can be performed on the data.
In this video , this topic is covered in-detail.
Documentation Link:
---------------------------------------
https://docs.snowflake.com/en/user-guide/data-time-travel.html#data-retention-period
Prerequisite:
-------------------------
Snowflake Time Travel
https://youtu.be/Eo4WSnQTwb4
Undrop a Table, Database or Schema | Snowflake Interview Question
https://youtu.be/WdZfLPhltXc
Code:
-----------------
drop database ramu;
create database ramu;
CREATE TABLE RAMU.PUBLIC.hello_world as select * from SNOWFLAKE_SAMPLE_DATA.TPCH_SF10.CUSTOMER limit 1000;
select * from RAMU.PUBLIC.hello_world;
show tables like 'hello_world' in RAMU.PUBLIC;
drop table RAMU.PUBLIC.hello_world;
select * from RAMU.PUBLIC.hello_world;
undrop table RAMU.PUBLIC.hello_world;
select * from RAMU.PUBLIC.hello_world;
ALTER TABLE RAMU.PUBLIC.hello_world SET DATA_RETENTION_TIME_IN_DAYS=0;
drop table RAMU.PUBLIC.hello_world;
select * from RAMU.PUBLIC.hello_world;
undrop table RAMU.PUBLIC.hello_world;
select * from RAMU.PUBLIC.hello_world;
------------------------------------------------------------------------------------------
create or replace TABLE HELLO_WORLD1 (
C_CUSTKEY NUMBER(38,0),
C_NAME VARCHAR(25),
C_ADDRESS VARCHAR(40),
C_NATIONKEY NUMBER(38,0),
C_PHONE VARCHAR(15),
C_ACCTBAL NUMBER(12,2),
C_MKTSEGMENT VARCHAR(10),
C_COMMENT VARCHAR(117)
) data_retention_time_in_days=45;
show tables like 'HELLO_WORLD1' in RAMU.PUBLIC;
------------------------------------------------------------------------------------------------------------------------------------
--There may be a 1-2 hour delay in updating storage related statistics
SELECT * FROM "SNOWFLAKE"."ACCOUNT_USAGE"."TABLE_STORAGE_METRICS" ;
SELECT ID,TABLE_NAME,TABLE_SCHEMA,TABLE_CATALOG,ACTIVE_BYTES/(1024*1024*1024) as STORAGE_USED_GB,
TIME_TRAVEL_BYTES/(1024*1024*1024) as TIME_TRAVEL_STORAGE_USED_GB from "SNOWFLAKE"."ACCOUNT_USAGE"."TABLE_STORAGE_METRICS"
order by STORAGE_USED_GB desc , TIME_TRAVEL_STORAGE_USED_GB desc;
Check this playlist for more Data Engineering related videos:
https://youtube.com/playlist?list=PLjfRmoYoxpNopPjdACgS5XTfdjyBcuGku
Snowflake Complete Course from scratch with End-to-End Project with in-depth explanation--
https://doc.clickup.com/37466271/d/h/13qc4z-104/d4346819bd8d510
🙏🙏🙏🙏🙏🙏🙏🙏
YOU JUST NEED TO DO
3 THINGS to support my channel
LIKE
SHARE
&
SUBSCRIBE
TO MY YOUTUBE CHANNEL
Видео Data Retention Period in Snowflake канала Knowledge Amplifier
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![Segmentation using Watershed Algorithm in Matlab | Practice Problem](https://i.ytimg.com/vi/uJquG-UI104/default.jpg)
![AWS S3 Bucket policies in-depth intuition](https://i.ytimg.com/vi/uKgIlFM6aP4/default.jpg)
![Demonstration of Facial Expression Recognition Using LBP Feature](https://i.ytimg.com/vi/i7EjCeBCsN4/default.jpg)
![Interactive Image Segmentation In-depth Intuition](https://i.ytimg.com/vi/l4n6LoNNpgE/default.jpg)
![Read CSV Data from External Stage & write in Permanent Snowflake Table using Snowflake Snowpark](https://i.ytimg.com/vi/JPQPsTA0N8E/default.jpg)
![Random Forest Classifier and Regressor (In-depth Intuition)](https://i.ytimg.com/vi/lvU2MApOTIs/default.jpg)
![How are k-means clustering algorithms sensitive to outliers?](https://i.ytimg.com/vi/SsmrcLAfbCA/default.jpg)
![Implementing Row Access Policies in Snowflake](https://i.ytimg.com/vi/GjLW9Vo-0_A/default.jpg)
![Apache Kafka Rebalance Listener & Implementing a database sink for Kafka](https://i.ytimg.com/vi/b3bS4KLpwQs/default.jpg)
![Processing Complex Type & Producing Messages to Topic using Faust](https://i.ytimg.com/vi/DpTJYtiYK9w/default.jpg)
![Automate the partition creation process in AWS Athena in-depth explanation](https://i.ytimg.com/vi/ybvpGJMUg9U/default.jpg)
![In depth intuition on Manual Offset Commits & At Least Once Processing in Kafka Consumer](https://i.ytimg.com/vi/pavNd_LT9nI/default.jpg)
![Mastering Data Validation🔍 : Building a Metadata-Driven Framework for Error-Free Data🎯](https://i.ytimg.com/vi/Rp0RHsT0jIA/default.jpg)
![Build and automate Serverless DataLake using an AWS Glue , Lambda , Cloudwatch](https://i.ytimg.com/vi/3f7UY5R9Q9U/default.jpg)
![Error Handling in Kafka Producer In-Depth Intuition](https://i.ytimg.com/vi/Sq9Idany-_o/default.jpg)
![Working with Group By Extensions – ROLLUP,CUBE,GROUPING SETS](https://i.ytimg.com/vi/QBJ-1q9prew/default.jpg)
![⚙️Automate Snowflake❄️ Reporting using Tasks, AWS Lambda , AWS SES 📧 | End-To-End Snowflake Project](https://i.ytimg.com/vi/PScK6OyL5RU/default.jpg)
![Building Real-Time Data Pipelines with Kafka , Faust & Snowflake](https://i.ytimg.com/vi/1ZQfXplyIO4/default.jpg)
![Strategies for Kafka Topic Partitioning when key=null](https://i.ytimg.com/vi/-eo4IPUshRo/default.jpg)
![Practice Problem on Texture Segmentation Using Texture Filters](https://i.ytimg.com/vi/2jwu5QLYkKQ/default.jpg)