ALTER TAG

statementsupportedGovernance (policies, tags, data quality)

docs.snowflake.com ↗

Object: TAG

Modifies the properties for an existing tag, including renaming the tag and setting a masking policy on a tag. Any changes made to the tag go into effect when the next SQL query that uses the tag runs.

Syntax

supportedpartialnot supportednot scored

ALTER TAG [ IF EXISTS ] <name> RENAME TO <new_name>

ALTER TAG [ IF EXISTS ] <name> { ADD | DROP } ALLOWED_VALUES '<val_1>' [ , '<val_2>' [ , ... ] ]

ALTER TAG [ IF EXISTS ] <name> SET
  [ ALLOWED_VALUES '<val_1>' [ , '<val_2>' [ , ... ] ] ]
  [ MULTI_VALUE = TRUE ]
  [ PROPAGATE = { ON_DEPENDENCY_AND_DATA_MOVEMENT | ON_DEPENDENCY | ON_DATA_MOVEMENT }
    [ ON_CONFLICT = { '<string>' | ALLOWED_VALUES_SEQUENCE | MERGE } ] ]
  [ COMMENT = '<string_literal>' ]

ALTER TAG [ IF EXISTS ] <name> UNSET { ALLOWED_VALUES | PROPAGATE | ON_CONFLICT | COMMENT }

ALTER TAG [ IF EXISTS ] <name> SET DATA MOVEMENT POLICY <data_movement_policy_name> [ FORCE ]

ALTER TAG [ IF EXISTS ] <name> UNSET DATA MOVEMENT POLICY

ALTER TAG [ IF EXISTS ] <name> SET MASKING POLICY
  <masking_policy_name> [ , MASKING POLICY <masking_policy_2_name> , ... ] [ FORCE ]

ALTER TAG [ IF EXISTS ] <name> UNSET MASKING POLICY <masking_policy_name> [ , MASKING POLICY <masking_policy_2_name> , ... ]

Parameters

NameRequiredDescription
nameIdentifier for the tag. Assign the tag string value on an object using either a CREATE <object> statement or an ALTER <object> statement. The identifier value must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (e.g. “My object”). Identifiers enclosed in double quotes are also case-sensitive. For more details, see Identifier requirements
RENAME TO new_nameSpecifies the new identifier for the tag; must be unique for your schema. The new identifier cannot be used if the identifier is already in place for a different tag. For more details, see Identifier requirements. You can move the object to a different database and/or schema while optionally renaming the object. To do so, specify a qualified new_name value that includes the new database and/or schema name in the form db_name.schema_name.object_name or schema_name.object_name, respectively. Note The destination database and/or schema must already exist. In addition, an object with the same name cannot already exist in the new location; otherwise, the statement returns an error. Moving an object to a managed access schema is prohibited unless the object owner (that is, the role that has the OWNERSHIP privilege on the object) also owns the target schema.
ALLOWED_VALUES 'val_1' [ , 'val_2' [ , ... ] ]Specifies a comma-separated list of the possible string values that can be assigned to the tag when the tag is set on an object using the corresponding CREATE <object> or ALTER <object> command. The maximum number of tag values in this list is 5,000. If you use the SET ALLOWED_VALUES clause, the specified values replace previously specified values, which allows you to adjust the sequence of values atomically. Using the DROP ALLOWED_VALUES clause to remove all values prevents someone from setting the tag to a value. If your intention is to let users set the tag to any value, use UNSET ALLOWED_VALUES instead. Changing or removing allowed values doesn’t affect values already assigned to objects. For more information, see Set a list of allowed tag values. If a tag is configured to automatically propagate to target objects, the order of values in the allowed list can affect how conflicts are resolved. For more information, see Tag propagation conflicts. Default: NULL (all string values are allowed, including an empty string value (that is, ' ')).
MULTI_VALUE = TRUEConverts the tag so it can store more than one string value on the same object or column. After you set this property, you can’t unset it or set it to FALSE. For more information, see Multi-value tags.
PROPAGATE = { ON_DEPENDENCY_AND_DATA_MOVEMENT | ON_DEPENDENCY | ON_DATA_MOVEMENT }Enterprise Edition Feature This parameter requires Enterprise Edition or higher. To inquire about upgrading, please contact Snowflake Support. Specifies that the tag will be automatically propagated from source objects to target objects. You can configure the tag to propagate when there is an object dependency, data movement, or both. Changes to this parameter do not automatically propagate to target objects. These changes have no effect on tags that were previously applied to target objects as part of tag propagation. Possible values are:
  • ON_DEPENDENCY_AND_DATA_MOVEMENT — Propagates the tag when there is an object dependency or data movement.
  • ON_DEPENDENCY — Propagates the tag for object dependencies, but not for data movement.
  • ON_DATA_MOVEMENT — Propagates the tag when there is data movement, but not for object dependencies.
ON_CONFLICT = { 'string' | ALLOWED_VALUES_SEQUENCE | MERGE }Enterprise Edition Feature This parameter requires Enterprise Edition or higher. To inquire about upgrading, please contact Snowflake Support. Specifies what happens when there is a conflict between the values of propagated tags. If you don’t set this parameter and there is a conflict, the value of the tag is set to the string CONFLICT. Changes to this parameter do not automatically propagate to target objects. These changes have no effect on tags that were previously applied to target objects as part of tag propagation. Possible values are: Default: Set the value of the tag to CONFLICT.
  • 'string' — When there is a conflict, the value of the tag is set to the specified string.
  • ALLOWED_VALUES_SEQUENCE — The order of the values in the ALLOWED_VALUES property of the tag determines which value is used when there is a conflict. For example, suppose you created a tag with the following statement:Copy code CREATE TAG my_tag ALLOWED_VALUES 'blue', 'red' PROPAGATE = ON_DEPENDENCY; If there is a conflict, then the value of my_tag will be blue because it comes before red in the allowed values list.
  • MERGE — Combines conflicting tag values into multiple values on the target object. You can set ON_CONFLICT = MERGE only when MULTI_VALUE = TRUE. For more information, see Multi-value tags.
SET DATA MOVEMENT POLICY data_movement_policy_name [ FORCE ]Attaches a data movement policy to the tag. When this tag is set on a column, table, schema, or database, the data movement policy governs data movement operations on the tagged object. If a data movement policy is already set on the tag, use FORCE to replace it without having to unset the existing policy first.
UNSET DATA MOVEMENT POLICYRemoves the data movement policy from the tag.
MASKING POLICY masking_policy_name [ , MASKING POLICY masking_policy_2_name , ... ]Specifies a comma-separated list of masking policies that can be assigned to the tag.
FORCEReplaces a masking policy that is currently set on a tag with a different masking policy in a single statement. Note that using the FORCE keyword replaces the masking policy when a policy of the same data type is already set on the tag. If a masking policy is not currently set on the tag, specifying this keyword has no effect. For details, see Replace a masking policy on a tag.
COMMENT = 'string_literal'Specifies a comment for the tag. Default: No value
UNSETSpecifies one (or more) properties and/or parameters to unset for the tag, which resets them to the defaults: ALLOWED_VALUES PROPAGATE ON_CONFLICT COMMENT

Usage notes

Access control requirements

A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes OWNERSHIP | Tag | This privilege is required to modify tag properties (e.g. comment, allowed values). OWNERSHIP is a special privilege on an object that is automatically granted to the role that created the object, but can also be transferred using the GRANT OWNERSHIP command to a different role by the owning role (or any role with the MANAGE GRANTS privilege). APPLY DATA MOVEMENT POLICY | Account | Assigning and replacing a data movement policy on a tag requires the global APPLY DATA MOVEMENT POLICY privilege. APPLY MASKING POLICY | Account | Assigning and replacing a masking policy on a tag requires the global APPLY MASKING POLICY privilege. Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema. For instructions on creating a custom role with a specified set of privileges, see Creating custom roles. For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control. For additional details on tag DDL and privileges, see Access control privileges.

See also

Referenced by