
Unlock this content
Enter your email to unlock this content for free
Enum
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)