📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

CREATE TAG



Creates a new tag. Tags are tenant-level metadata objects that can be assigned to database objects for governance and classification.

See also: DROP TAG, SHOW TAGS, SET TAG / UNSET TAG.

Syntax

CREATE TAG [ IF NOT EXISTS ] <tag_name> [ ALLOWED_VALUES = ( '<value1>' [, '<value2>', ... ] ) ] [ COMMENT = '<string>' ]
ParameterDescription
tag_nameName of the tag to create.
ALLOWED_VALUESOptional list of permitted values. When set, only these values can be used in SET TAG. Duplicate values are removed automatically.
COMMENTOptional description for the tag.

Examples

Create a tag with allowed values and a comment:

CREATE TAG env ALLOWED_VALUES = ('dev', 'staging', 'prod') COMMENT = 'Environment classification';

Create a tag that accepts any value:

CREATE TAG owner COMMENT = 'Data owner';

Create a tag with no restrictions:

CREATE TAG cost_center;

Verify tag definitions:

SELECT name, allowed_values, comment FROM system.tags ORDER BY name; ┌──────────────────────────────────────────────────────────────────────┐ │ name │ allowed_values │ comment │ ├────────────────┼────────────────────────────┼────────────────────────┤ │ cost_center │ NULL │ │ │ env │ ['dev', 'staging', 'prod'] │ Environment classific… │ │ owner │ NULL │ Data owner │ └──────────────────────────────────────────────────────────────────────┘

Was this page helpful?