2025 Tables and Views Flashcards

1
Q

What are the four types of tables in Snowflake

A

Permanent
Transient
Temporary
External

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How long is the Fail Safe period

A

7 days immediately after the Time Travel retention period.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the max number of days Time Travel can be set for

A

90 days

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In the Snowflake standard addition, what is the Time Travel period allowed to be set for?

A

0 - 1 day

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the minimum edition to set Time Travel to more than 1 day?

A

Enterprise

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the parameter to set Time Travel?

A

DATA_RETENTION_TIME_IN_DAYS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between a Transient Table and a Permanent Table

A

Transient Tables have no Fail-Safe and limit time travel, max 1 day which is the default

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Can a transient table be converted to another type of table after being created

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When would you use a Transient Table

A
  • When you have a lot of data but protection is not a concern.
  • When data can be recovered from external means if required.
  • Can be used to store data that should be maintained between sessions, but can be recovered in case of a system failure
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the difference between Temporary Tables and other tables

A

These tables are only for the duration of the session and are only visible to the user. Once the session completes, the table is purce and nonrecoverable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How long is the Time Travel retention period on a Temporary Table?

A

1 day or the reminder of the session, whichever is smaller

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Once created, can a temporary table be changed?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

For an External Table, what is stored in Snowflake?

A

The metadata, like the name of the file, the row number of each record, etc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Can you perform DML operations on an External Table?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What can be done to improve performance when querying an external table?

A

You can build a Materialized View on top of the table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What columns are included in external tables?

A

VALUE: the VARIANT field representing a single record in the file
METADATA$FILENAME: name and path of each staged file
METADATA$FILE_ROW_NUMBER: the row number of each staged file record

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What does the command ALTER EXTERNAL TABLE … REFRESH do?

A

Once completed, the following activities are supported:
* Adds new files to table metadata
* Updates file changes in table metadata
* Removes files no longer available from table metadata

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is an option for triggering automatic refreshes of an External Table’s metadata?

A

Event Notification for Cloud Storage.
There is a charge of .06 per 1,000 event notifications

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Can the types permanent/transient/temporary be applied to other database objects?

A

Yes, like Schemas and Databases. Everything created in those objects will inherit the type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What happens when a temporary table and a non-temporary table have the same name?

A

Both are available but the temporary one takes precedence.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Is CREATE TABLE required to create Temporary Tables

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is the minimum edition required for 0-1 days of time travel on Temporary or Transient Tables

A

Enterprise

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is MAX_DATA_EXTENSION_TIME_IN_DAYS

A

Max number of days Snowflake can extended the data retention period for tables to prevent streams on the tables from becoming stale.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is the default for MAX_DATA_EXTENSION_TIME_IN_DAYS

A

14 days, can be set 0 to 90

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

On a CREATE TABLE statement, what does this mean:
ERROR_ON_COLUMN_COUNT_MISMATCH = TRUE

A

Of the number of delimited columns in a n input file does not match the number of columns in the Snowflake table, it generates a parsing error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What is NULL_IF used for

A

Used to convert to and from SQL NULL.
This option can be used for string conversion from SQL NULL to the first value in the list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

On a CREATE TABLE statement, what does this mean:
STRIP_OUTER_ARRAY = TRUE

A

Allows the JSON parser to remove the outer array and load records in separate rows. Used often with VARIANT data types when the data exceeds 16 MB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What are some examples of reserved keywords that should not be used as column identifiers

A

CURRENT_DATE
CURRENT_ROLE
CURRENT_TIME

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

How do you disable Time Travel for a table

A

Set DATA_RETENTION_TIME_IN_DAYS=0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

What does the Top<n> do in a SELECT statement</n>

A

Returns the top n rows, remember to use ORDER BY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

How do you convert from JSON NULL to SQL NULL on a SELECT statement

A

STRIP_NULL_VALUE(<col>)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

Where can STATEMENT_TIMEOUT_IN_SECONDS be set

A

At the Session or the Warehouse level, the lowest takes precedence

33
Q

What is the default for STATEMENT_TIMEOUT_IN_SECONDS

34
Q

What is the purpose of RESULT_SCAN

A

Returns the previous command as a table. It should be executed within 24 hours of query execution.

35
Q

What is the syntax of RESULT_SCAN

A

RESULT_SCAN(‘query_id’|last_query_id())

36
Q

What are the different data types for date/time information

A

DATE
DATETIME
TIME
TIMESTAMP

37
Q

What are the three variations of TIMESTAMP

A

TIMESTAMP_LTZ
TIMESTAMP_NTZ
TIMESTAMP_TZ

38
Q

Define TIMESTAMP_LTZ

A

Stores UTC time with a defined precision. All operations are performed in the current session’s time zone.

39
Q

Define TIMESTAMP_NTZ

A

Stores wall clock time with specified precision. All operations are performed without taking any time zone

40
Q

TIMESTAMP_TZ

A

Stores UTC time with a time zone offset. All operations are performed with a record specific time zone offset

41
Q

What are the three type of VIEWS

A

Regular (nonmaterialized)
Materialized
Secure

42
Q

Why are Views slower than Materialized Views

A

Regular view results are not stored for future use. Associated SQL queries should be executed again every time a view is accessed

43
Q

What costs are associated with Materialized Views

A

Storage and Compute

44
Q

Does Snowflake automatically maintain Materialized Views

A

Yes, because of this, Materialized Views always have access to the latest table data

45
Q

How can you tell when a Materialized View is refreshed

A

The view has the columns REFRESHED_ON and BEHIND_BY

46
Q

Where can you find Materialized Views in the Information_Schema

A

Tables
NOT VIEWS

47
Q

T/F Materialized Views are more flexible than cached results and faster than tables because they use the “cache”

48
Q

Can Materialized Views also support data to be hidden at the row and column levels

49
Q

If the base table data changes before a query on the materialized view is updated, does the user experience an impact?

A

No, Snowflaker will either first update the materialized view or use updated portions of the materialized view and retrieve any new data from the base table.

50
Q

What are some valid use cases for a materialized view

A
  • Smaller subset of the base table
  • The SQL requires significant processing
  • Based on an external table
  • Base table does not change frequently
51
Q

If a user has access to a view or materialized view, do they also need access to the base table(s) to see results

53
Q

What cannot be queried in a materialized view?

A

Any other view/user-defined table functions

Materialized views are limited to their own data and cannot reference other views or user-defined functions.

54
Q

Which SQL clauses are not allowed in a materialized view?

A

UDFs, HAVING, JOIN, ORDER BY, LIMIT, GROUP BY

These restrictions limit the complexity of the queries that can be used to define materialized views.

55
Q

What operations are generally not allowed in a materialized view?

A

Many aggregate functions or DML operations

This limitation affects the ability to perform certain calculations or data modifications directly within the view.

56
Q

Can users truncate materialized views?

A

No

Truncating a materialized view is not permitted, which affects data management strategies.

57
Q

What happens when a schema containing a materialized view is cloned?

A

The materialized view will be cloned and included in the new schema or database

This ensures that materialized views are preserved during schema cloning.

58
Q

Is Time Travel allowed on materialized views?

A

No

Time Travel functionality does not apply to materialized views, limiting historical data access.

59
Q

What happens if the base columns of a Materialized view are dropped?

A

All materialized views on the bas table are suspended and users must re-create the view again.

60
Q

When would you use a materialized view instead of a regular view

A

The SQL is computationally expensive and is repeatedly executed on relatively stable data.

61
Q

When would you use a view instead of a materialized view

A

Views are more flexible and are best when the results change often, the view isn’t used often, or the query is not intensive.

62
Q

Why might you experience an impact on performance for Secure Views

A

While evaluating them, the query optimizer bypasses a few optimizations.

63
Q

What command can be used to identify secure views?

A

SHOW MATERIALIZED VIEWS

64
Q

What makes a secure view different

A

Designed for data privacy and limit access to the data definition of the view

65
Q

How do you change a view to a secure view

A

ALTER VIEW <view-name> SET SECURE;</view-name>

66
Q

If a user only has access the secure view and not the underlying table, where are they limited

A

They can’t see the SQL definition, this includes in the INFORMATION_SCHEMA and the SHOW commands

67
Q

When would you use FLATTEN

A

When you need to access elements with JSON arrays and convert them to rows

68
Q

When would you use PARSE_JSON

A

When you have JSON stored as strings that need to be converted to VARIANT

69
Q

When you want to convert hierarchical data into a relational format, which would you use FLATTEN or PARSE JSON

70
Q

How can you organize your underlying data for external tables if you want to partition it

A

Using logical paths that include date, time, country or similar dimensions in the poath

71
Q

How can you add partitions to your external table

A

Automatically by refereshing the external table
Manually

72
Q

When are partition columns defined for an external table

A

When created using PATITION BY. After creations, the method by which partitions are added cannot be changed

73
Q

When a SNS topic that is associated with a pipe is deleted, does the pipe autosuspend

A

No, it will attempt to ingest data and fail.

74
Q

What edition is required for materialize views

A

Enterprise

75
Q

Which table only exists within the user’s session, Transient or Temporary

76
Q

All external tables include what columns

A

VALUE
METADATA$FILENAME
METADATA$FILE_ROW_NUMBER

77
Q

What type of tables can be cloned

A

Transient
Permanent

78
Q

What is the difference between JSON NULL and SQL NULL

A

In JSON a null value represents a string null, which prevents the extraction of those elements.
SQL null is an empty value
JSON NULL can lead to performance issues.