You are on page 1of 13

Table Types

by
Veerendra.v
Types of Tables
Snowflake supports three types of tables

1. Permanent tables
2. Transient tables
3. Temporary tables
Permanent Tables
 Default table type in Snowflake
 These are the regular and common tables
 Tables exists until we drop them explicitly
 7 days of fail-safe period
 Syntax to create Permanent table is
 Permanent table can be guarded by time travel as per edition of choice. Standard edition(0 or 1)
& Enterprise edition or higher(1 to 90).
 7 days fail-safe for permanent table.
 Query cache is supported for 24 hours.

CREATE TABLE RAJIVTABLE (ID NUMBER, CREATION_DATE DATE);


Use-Case:
For all persistence data storage business case.

Want an option to recover deleted history data between 1–90 days.

Want data protection in fail-safe period.


Transient Tables
 Similar to Permanent tables but with 1 day retention period
 No fail-safe period
 Transient table contribute to storage charges for the duration it was holding
data just like permanent table.
 Tables exists until we drop them explicitly
 Useful when data protection is not required
 Defining stage tables as Transient is best practice
 Transient table cannot be converted to any other table type.
 Time travel for transient table is 0–1 days.
 No fail-safe for transient table
 To create transient table we have to use below syntax sample.
 CREATE TRANSIENT TABLE RAJIVTABLE (ID NUMBER,
CREATION_DATE DATE);
EX: CREATE TRANSIENT TABLE RAJIVTABLE (ID NUMBER, CREATION_DATE DATE);

Use-Case:
• Need feature like permanent table but want cost-effective solution.
• Don't want to protect data for fail-safe period.
• Want an option to recover deleted history data for max 1 day is required.
• Specifically designed for transitory data that needs to be maintained beyond each
session.
Temporary Tables
 Table exists only within the session
 Once the session ends, table gets dropped completely and is not recoverable.
 They are not visible to other users or sessions
 1 day retention period
 No fail-safe period
 Useful for development work
 Can be used in stored procedures for intermediate data storing
 Syntax to create Temporary table is
CREATE TEMPORARY TABLE TABLE_NAME();
EXP

Syntax : CREATE TEMPORARY TABLE RAJIVTABLE (ID NUMBER, CREATION_DATE


DATE);
Use-Case:
• For any temporary data requirement.
• For ETL process where you want to store some intermediary session data which you don't
need outside the current session.
• No data protection required beyond session.
Points to Remember
 We can’t convert any type of table to other type
 We can create Transient databases and Transient schemas
 Tables created under Transient databases/schemas are by default
Transient
 We can create a temporary table with same name as Perm/Tran table. If
we query with that table name, it fetches data from Temporary table in
that session.
 How to find the table type?
Look at the ‘Kind’ filed in SHOW TABLES properties
Comparison of Tables

Time-Travel Fail-Safe
Table Type Persistence Retention period period in
in days days

Until session is
Temporary 0 or 1 (default is 1) 0
active

Until explicitly
Transient 0 or 1 (default is 1) 0
dropped

Permanent Until explicitly


0 or 1 (default is 1) 7
(Standard Edition) dropped

Permanent Until explicitly 0 to 90 (default is 1, can be


7
(Enterprise and higher) dropped modified)
Use cases :
•Perform temporary data manipulation operations
Each of these table types has its own unique features
and use cases, and understanding the differences
between them can help you choose the appropriate
table type for your specific needs.
Thank You

You might also like