CREATE TAG

statementsupportedGovernance (policies, tags, data quality)

docs.snowflake.com ↗

Object: TAG

Creates a new tag or replaces an existing tag in the system. This command supports the following variants: - CREATE OR ALTER TAG: Creates a tag if it doesn’t exist or alters an existing tag. - DEFINE TAG: Declarative definition of a tag’s target state inside a DCM project.

Syntax

supportedpartialnot supportednot scored

CREATE [ OR REPLACE ] TAG [ IF NOT EXISTS ] <name>
    [ 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>' ]

For more information, see CREATE OR ALTER TAG usage notes and CREATE OR ALTER <object>.

CREATE OR ALTER TAG <name>
  [ ALLOWED_VALUES '<val_1>' [ , '<val_2>' [ , ... ] ] ]
  [ COMMENT = '<string_literal>' ]

Parameters

NameRequiredDescription
namerequiredIdentifier 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 (for example, “My object”). Identifiers enclosed in double quotes are also case-sensitive. For more details, see Identifier requirements.
ALLOWED_VALUES 'val_1' [ , 'val_2' [ , ... ] ]optionalSpecifies 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. Must come before all other parameters to work. The maximum number of tag values in this list is 5,000. 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 = TRUEoptionalSpecifies that the tag 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. To add or remove values on an object, use ADD VALUE and DROP VALUE. For more information, see Multi-value tags. Default: The tag stores a single value.
PROPAGATE = { ON_DEPENDENCY_AND_DATA_MOVEMENT | ON_DEPENDENCY | ON_DATA_MOVEMENT }optionalEnterprise 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.
  • 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 }optionalEnterprise 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. 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 ON_CONFLICT = ALLOWED_VALUES_SEQUENCE; 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.
COMMENT = 'string_literal'optionalSpecifies a comment for the tag. Default: No value

Access control requirements

A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes CREATE TAG | Schema | OWNERSHIP | Tag | Required to execute a CREATE OR ALTER TAG statement for an existing tag. 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.

General usage notes

- You must set the ALLOWED_VALUES parameter before all other parameters, such as COMMENT. - For more information about how tags can be associated with Snowflake objects, see Introduction to object tagging. - For more information about tag DDL authorization, see required privileges. - Regarding metadata: Attention Customers should ensure that no personal data (other than for a User object), sensitive data, export-controlled data, or other regulated data is entered as metadata when using the Snowflake service. For more information, see Metadata fields in Snowflake. - The OR REPLACE and IF NOT EXISTS clauses are mutually exclusive. They can’t both be used in the same statement. - CREATE OR REPLACE <object> statements are atomic. That is, when an object is replaced, the old object is deleted and the new object is created in a single transaction.

CREATE OR ALTER TAG usage notes

- When you use this command, all unspecified parameters are reset. For example, if you specify a new comment only, then the PROPAGATE parameter no longer enables tag propagation. - All limitations of the ALTER TAG command apply. - Setting or unsetting a masking policy is not supported.

See also

Referenced by