Object Tagging is a feature for attaching key-value metadata tags to Snowflake database objects (tables, views, columns, schemas, databases, and more). It is used for data classification (PII, sensitivity levels, etc.), cost allocation, and compliance management. Combined with Tag-based Masking / Row Access Policy, it enables automatic data protection based on tag values. Available in Enterprise Edition or higher.
-- Creating a basic tag
CREATE TAG governance.data_classification;
-- Creating a tag with allowed values
CREATE TAG governance.pii_level
ALLOWED_VALUES 'HIGH', 'MEDIUM', 'LOW', 'NONE';
-- Tag used for cost allocation
CREATE TAG governance.cost_center
ALLOWED_VALUES 'ENGINEERING', 'MARKETING', 'FINANCE', 'HR';
-- Add a comment to the tag
CREATE TAG governance.data_owner
COMMENT = 'Tag that records the owning department for the data';-- Set a tag on a table
ALTER TABLE hr.employees
SET TAG governance.data_classification = 'CONFIDENTIAL';
-- Set a tag on a column
ALTER TABLE hr.employees
ALTER COLUMN ssn
SET TAG governance.pii_level = 'HIGH';
ALTER TABLE hr.employees
ALTER COLUMN email
SET TAG governance.pii_level = 'MEDIUM';
ALTER TABLE hr.employees
ALTER COLUMN department
SET TAG governance.pii_level = 'NONE';
-- Set a tag on a schema (inherited by the objects beneath it)
ALTER SCHEMA hr
SET TAG governance.data_owner = 'HR_DEPARTMENT';
-- Set a tag on a database
ALTER DATABASE analytics
SET TAG governance.cost_center = 'ENGINEERING';
-- Set a tag on a warehouse
ALTER WAREHOUSE compute_wh
SET TAG governance.cost_center = 'ENGINEERING';
-- Change a tag value
ALTER TABLE hr.employees
ALTER COLUMN ssn
SET TAG governance.pii_level = 'MEDIUM';
-- Unset a tag
ALTER TABLE hr.employees
ALTER COLUMN ssn
UNSET TAG governance.pii_level;Tag-based Masking is a mechanism that automatically applies a Masking Policy or Row Access Policy based on tag values. Once you associate a policy with a tag, the policy is automatically applied to any column where that tag is set. Because applying a policy is as simple as adding a tag to a column, governance management scales efficiently in environments with large numbers of tables and columns.
-- Masking Policy for PII HIGH
CREATE OR REPLACE MASKING POLICY mask_pii_high
AS (val VARCHAR) RETURNS VARCHAR ->
CASE
WHEN IS_ROLE_IN_SESSION('DATA_STEWARD') THEN val
WHEN IS_ROLE_IN_SESSION('COMPLIANCE') THEN val
ELSE '********'
END;
-- Masking Policy for PII MEDIUM
CREATE OR REPLACE MASKING POLICY mask_pii_medium
AS (val VARCHAR) RETURNS VARCHAR ->
CASE
WHEN IS_ROLE_IN_SESSION('DATA_STEWARD') THEN val
ELSE CONCAT(LEFT(val, 2), '****')
END;
-- Attach the Masking Policy to the tag
ALTER TAG governance.pii_level
SET MASKING POLICY mask_pii_high;
-- You can attach a different policy per tag value
-- (though only one policy per data type for a given tag)
-- As a result, mask_pii_high is applied automatically to every column
-- tagged with pii_level = 'HIGH'-- Check the tags set on a specific table
SELECT *
FROM TABLE(
INFORMATION_SCHEMA.TAG_REFERENCES('hr.employees', 'TABLE')
);
-- Check the tags set on a specific column
SELECT *
FROM TABLE(
INFORMATION_SCHEMA.TAG_REFERENCES('hr.employees.ssn', 'COLUMN')
);
-- Check the tags on every column of a table at once
SELECT *
FROM TABLE(
INFORMATION_SCHEMA.TAG_REFERENCES_ALL_COLUMNS('hr.employees', 'TABLE')
);
-- Check account-wide tag usage through the Account Usage views
SELECT
tag_name,
tag_value,
object_name,
column_name,
domain -- TABLE, COLUMN, SCHEMA, DATABASE, WAREHOUSE, and so on
FROM SNOWFLAKE.ACCOUNT_USAGE.TAG_REFERENCES
WHERE tag_name = 'PII_LEVEL'
ORDER BY object_name;
-- Count objects per value of a given tag
SELECT
tag_value,
domain,
COUNT(*) AS object_count
FROM SNOWFLAKE.ACCOUNT_USAGE.TAG_REFERENCES
WHERE tag_name = 'PII_LEVEL'
GROUP BY tag_value, domain
ORDER BY tag_value;| Tag Set On | Inheriting Objects |
|---|---|
| Database | All Schemas → all Tables/Views → all Columns |
| Schema | All Tables/Views in the Schema → all Columns |
| Table/View | All Columns in the Table/View |
| Column | No inheritance (lowest-level object) |
When you set a tag directly on a lower-level object, that value takes precedence over inherited values. For example, if you set pii_level = 'LOW' on a schema and pii_level = 'HIGH' on a specific column,'HIGH' is the effective value for that column.
-- Privilege to create tags
GRANT CREATE TAG ON SCHEMA governance TO ROLE tag_admin;
-- Privilege to apply tags
GRANT APPLY TAG ON ACCOUNT TO ROLE tag_admin;
-- Extra privileges needed to set up Tag-based Masking Policies
GRANT APPLY MASKING POLICY ON ACCOUNT TO ROLE tag_admin;
-- List the tags
SHOW TAGS IN SCHEMA governance;
-- Tag details
DESCRIBE TAG governance.pii_level;Security & Governance
Question 1
A Masking Policy is associated with the governance.pii_level tag. A data engineer runs ALTER TABLE ... ALTER COLUMN phone_number SET TAG governance.pii_level = 'HIGH' on the phone_number column of the hr.employees table. Which of the following is the correct result?
Correct answer: B
With Tag-based Masking, once a Masking Policy is associated with a tag, the policy is automatically applied to any column where that tag is set. Because attaching a tag is enough to apply the Masking Policy, individual policy attachment is no longer required, making governance management efficient in large-scale environments. Data is not physically masked; masking is applied dynamically at query time.
When a tag is dropped, is the Tag-based Masking Policy also automatically detached?
When you drop a tag with DROP TAG, any Tag-based Masking / Row Access Policy associations attached to that tag are automatically detached. However, the policy objects themselves are not deleted. Similarly, when you UNSET TAG from a column or table, Tag-based policy application to that object is removed. Before dropping a tag, it is recommended to check the impact with the TAG_REFERENCES function.
What constraints apply to tag values?
Tag values are VARCHAR strings of up to 256 characters. If you set ALLOWED_VALUES, only the specified values can be assigned (up to 300 values). Without ALLOWED_VALUES, any string can be set. Tag values are case-sensitive, but tag names follow Snowflake's identifier rules and are converted to uppercase by default.
What is Tag Lineage?
Snowflake tags are automatically inherited through the object hierarchy. Setting a tag on a database propagates it to all schemas, tables, and columns within that database. Setting a tag on a schema propagates it to all tables and columns inside the schema. When a tag is set directly on a lower-level object, the explicit value overrides the inherited one. You can audit all tag assignments, including inherited ones, with the TAG_REFERENCES_ALL_COLUMNS function.
Practice with certification-focused question sets
Try free questionsNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
Snowflake Certifications: All 11 Exams Explained (2026)
Every SnowPro certification — Associate, Core, Specialty, Ad...
Snowflake Exam Difficulty Ranking: All 11 Certs Compared (2026)
All 11 SnowPro exams ranked by difficulty with study-time es...
Snowflake Study Guide: Fastest Pass Route by Exam (2026)
How to pass SnowPro certifications efficiently — official ma...
SnowPro Core (COF-C03): Complete Exam Guide (2026)
Pass the SnowPro Core exam — six domains, scope, sample ques...
SnowPro Associate Platform (SOL-C01): Complete Guide (2026)
The entry-level SnowPro Associate exam — scope, weighting, s...