0
0
Snowflakecloud~5 mins

Data classification and tagging in Snowflake - Commands & Configuration

Choose your learning style9 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.