Unlock this content

Enter your email to unlock this content for free

By continuing, you agree to our Terms of Service and Privacy Notice, and to receive occasional marketing emails.

Enum

TL;DR

Enum types store strings as integers, saving space and improving performance for small, predefined sets of values. They offer type safety but are hard to evolve. Consider LowCardinality(String) for more flexibility.

Enum Types

ClickHouse Enum types store a predefined set of string values as integers internally. Two types: Enum8 (up to 256 values, mapped to Int8) and Enum16 (up to 65,536 values, mapped to Int16).

Using Enum Columns

Define an Enum column by specifying allowed string values and their integer representations. Insert and query using string values; ClickHouse stores them as integers internally.

CREATE TABLE user_status ( user_id UInt32, status Enum8('active' = 1, 'inactive' = 2, 'pending' = 3, 'blocked' = 4)

Tinybird is not affiliated with, associated with, or sponsored by ClickHouse, Inc. ClickHouse® is a registered trademark of ClickHouse, Inc.

Enum | ClickHouse for Developers