Загрузка страницы

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
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
17 августа 2022 г. 20:52:31
00:10:40
Яндекс.Метрика