Bird
Raised Fist0
Snowflakecloud~5 mins

Data classification and tagging in Snowflake - Commands & Configuration

Choose your learning style10 modes available
Introduction
When you have many data tables, it can be hard to know what kind of data each table holds. Data classification and tagging help you label your data so you can find and protect it easily.
When you want to mark sensitive data like personal information to control who can see it
When you need to organize data by categories such as finance, marketing, or operations
When you want to quickly search for data tables based on their tags
When you need to comply with rules that require labeling data for privacy or security
When you want to track data usage by tagging data with ownership or purpose
Commands
This command creates a tag named 'sensitive_data' with a description explaining its purpose.
Terminal
CREATE TAG sensitive_data COMMENT = 'Marks data that contains sensitive information';
Expected OutputExpected
Tag SENSITIVE_DATA successfully created.
This command applies the 'sensitive_data' tag to the 'sales_data' table, marking it as sensitive.
Terminal
ALTER TABLE sales_data SET TAG sensitive_data = 'true';
Expected OutputExpected
Table SALES_DATA altered.
This command lists all tags matching the name 'sensitive_data' to verify the tag exists.
Terminal
SHOW TAGS LIKE 'sensitive_data';
Expected OutputExpected
created_on | name | database_name | schema_name | comment ---------------------|----------------|---------------|-------------|----------------------------- 2024-06-01 12:00:00 | SENSITIVE_DATA | MY_DATABASE | PUBLIC | Marks data that contains sensitive information
This command shows all tables that have the 'sensitive_data' tag applied, helping you find sensitive data quickly.
Terminal
SELECT TABLE_NAME, TAG_VALUE FROM INFORMATION_SCHEMA.TAG_REFERENCES WHERE TAG_NAME = 'SENSITIVE_DATA';
Expected OutputExpected
TABLE_NAME | TAG_VALUE -----------|---------- sales_data | true
Key Concept

If you remember nothing else from this pattern, remember: tagging data lets you label and find important data easily for security and organization.

Common Mistakes
Trying to apply a tag before creating it
Snowflake will return an error because the tag does not exist yet.
Always create the tag first using CREATE TAG before applying it to tables.
Using lowercase tag names in queries after creating tags with uppercase names
Snowflake treats tag names as case-insensitive but stores them uppercase, causing confusion in queries.
Use uppercase tag names in queries or double quotes to match exact case.
Not checking which tables have tags applied
You might miss important data that needs protection or organization.
Use INFORMATION_SCHEMA.TAG_REFERENCES to list tagged tables regularly.
Summary
Create tags with CREATE TAG to label data meaningfully.
Apply tags to tables with ALTER TABLE SET TAG to mark data.
Use SHOW TAGS and INFORMATION_SCHEMA.TAG_REFERENCES to verify and find tagged data.

Practice

(1/5)
1. What is the main purpose of data classification and tagging in Snowflake?
easy
A. To speed up query performance by indexing data
B. To convert data into different file formats
C. To automatically delete old data after a set time
D. To organize and protect data by labeling it with tags

Solution

  1. Step 1: Understand data classification and tagging

    Data classification and tagging help label data to organize and protect it.
  2. Step 2: Identify the purpose in Snowflake context

    Tags are used to mark data for governance and security, not for performance or deletion.
  3. Final Answer:

    To organize and protect data by labeling it with tags -> Option D
  4. Quick Check:

    Data classification = Organize and protect data [OK]
Hint: Tags label data to organize and protect it [OK]
Common Mistakes:
  • Confusing tagging with indexing for performance
  • Thinking tags delete data automatically
  • Assuming tags change data format
2. Which of the following is the correct syntax to create a tag in Snowflake?
easy
A. CREATE TAG tag_name COMMENT = 'description';
B. CREATE TAG tag_name WITH 'description';
C. MAKE TAG tag_name COMMENT 'description';
D. NEW TAG tag_name SET COMMENT = 'description';

Solution

  1. Step 1: Recall Snowflake tag creation syntax

    The correct syntax uses CREATE TAG followed by the tag name and COMMENT clause.
  2. Step 2: Compare options with syntax

    Only CREATE TAG tag_name COMMENT = 'description'; matches the correct syntax: CREATE TAG tag_name COMMENT = 'description';
  3. Final Answer:

    CREATE TAG tag_name COMMENT = 'description'; -> Option A
  4. Quick Check:

    CREATE TAG ... COMMENT = ... is correct syntax [OK]
Hint: Use CREATE TAG with COMMENT = 'text' [OK]
Common Mistakes:
  • Using MAKE or NEW instead of CREATE
  • Missing equal sign in COMMENT clause
  • Using WITH instead of COMMENT
3. Given the following commands, what will be the result of querying the tags on the customers table?
CREATE TAG pii COMMENT = 'Personally Identifiable Information';
ALTER TABLE customers SET TAG pii = 'true';
SHOW TAGS ON TABLE customers;
medium
A. It will show the tag 'pii' with value 'true' assigned to the customers table
B. It will show an error because tags cannot be set on tables
C. It will show the tag 'pii' but with no value assigned
D. It will show no tags because SHOW TAGS is invalid syntax

Solution

  1. Step 1: Understand tag creation and assignment

    The tag 'pii' is created and then assigned to the 'customers' table with value 'true'.
  2. Step 2: Check SHOW TAGS syntax and output

    SHOW TAGS ON TABLE customers; lists tags assigned to the table, showing 'pii' = 'true'.
  3. Final Answer:

    It will show the tag 'pii' with value 'true' assigned to the customers table -> Option A
  4. Quick Check:

    SHOW TAGS ON TABLE shows assigned tags [OK]
Hint: SHOW TAGS ON TABLE lists assigned tags and values [OK]
Common Mistakes:
  • Thinking tags cannot be assigned to tables
  • Assuming SHOW TAGS syntax is invalid
  • Expecting tags without values to appear
4. You run the following command but get an error:
ALTER TABLE orders SET TAG sensitive = 'yes';

What is the most likely cause of the error?
medium
A. ALTER TABLE cannot be used to set tags
B. The value 'yes' is not allowed for tags
C. The tag 'sensitive' was not created before assigning it
D. Tags can only be assigned to columns, not tables

Solution

  1. Step 1: Check if tag exists before assignment

    Tags must be created with CREATE TAG before assigning to tables or columns.
  2. Step 2: Analyze error cause

    If 'sensitive' tag was not created, assigning it causes an error.
  3. Final Answer:

    The tag 'sensitive' was not created before assigning it -> Option C
  4. Quick Check:

    Tags must exist before assignment [OK]
Hint: Create tags before assigning them [OK]
Common Mistakes:
  • Assuming any value is invalid
  • Thinking ALTER TABLE can't set tags
  • Believing tags only apply to columns
5. You want to classify columns in a payments table as either 'confidential' or 'public' using tags. Which approach correctly applies tags to columns and supports data governance?
hard
A. Create tags and assign them to database schemas instead of columns
B. Create tags 'confidential' and 'public', then assign them to each column with ALTER TABLE ... ALTER COLUMN ... SET TAG
C. Use column comments instead of tags to classify data sensitivity
D. Create tags and assign them only to the table, not columns, to simplify management

Solution

  1. Step 1: Understand tagging granularity

    Tags can be assigned to columns to classify data precisely, supporting governance.
  2. Step 2: Identify correct tagging method

    Using ALTER TABLE ... ALTER COLUMN ... SET TAG applies tags to columns, enabling classification.
  3. Final Answer:

    Create tags 'confidential' and 'public', then assign them to each column with ALTER TABLE ... ALTER COLUMN ... SET TAG -> Option B
  4. Quick Check:

    Column-level tags enable precise data classification [OK]
Hint: Tag columns directly for precise classification [OK]
Common Mistakes:
  • Tagging only tables loses column-level detail
  • Using comments instead of tags for governance
  • Assigning tags to schemas instead of columns
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard