Skip to main content

CREATE TAG

Introduced or updated: v1.2.863

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 │ NULLData owner │
└──────────────────────────────────────────────────────────────────────┘
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today