CREATE TAG

Creates a new tag or replaces an existing tag in the system.

See also:

Specify tag values , TAGS view , Tag DDL reference

Syntax

CREATE [ OR REPLACE ] TAG [ IF NOT EXISTS ] <name> [ COMMENT = '<string_literal>' ]

CREATE [ OR REPLACE ] TAG [ IF NOT EXISTS ] <name>
    [ ALLOWED_VALUES '<val_1>' [ , '<val_2>' [ , ... ] ] ]
    [ COMMENT = '<string_literal>' ]
Copy

Important

The parameter ALLOWED_VALUES must always be set before all other parameters, such as COMMENT, for ALLOWED_VALUES to work.

Required parameters

name

Identifier 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.

Optional parameters

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.

Must come before all other parameters to work.

The maximum number of tag values in this list is 300.

Default: NULL (all string values are allowed, including an empty string value (i.e. ' ')).

COMMENT = 'string_literal'

Specifies a comment for the tag.

Default: No value

Access control requirements

A role used to execute this SQL command must have the following privileges at a minimum:

Privilege

Object

Notes

CREATE TAG

Schema

The USAGE privilege on the parent database and schema are required to perform operations on any object in a 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 Managing tags.

Usage notes

  • Snowflake limits the number of tags in an account to 10,000.

  • For more information on how tags can be associated to Snowflake objects, see Object Tagging.

  • For more information on 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.

  • 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.

Examples

Create a tag with the key cost_center.

CREATE TAG cost_center COMMENT = 'cost_center tag';
Copy