ApsaraDB for ClickHouse supports the data types listed in this reference. For the complete upstream type system, see Data Types in the open-source ClickHouse documentation.
Supported data types
Integer
Signed integers. Use the smallest type that covers your value range to minimize storage.
| Keyword | Range |
|---|---|
Int8 | –128 to 127 |
Int16 | –32,768 to 32,767 |
Int32 | –2,147,483,648 to 2,147,483,647 |
Int64 | –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
For unsigned integers (UInt8, UInt16, UInt32, UInt64), see Integer types in the ClickHouse documentation.
Floating-point
| Keyword | Description |
|---|---|
Float32 | Single-precision floating-point. Equivalent to FLOAT in C++. Takes 4 bytes; 32-bit binary. |
Float64 | Double-precision floating-point. Equivalent to DOUBLE in C++. Takes 8 bytes; 64-bit binary. |
For financial or business data that requires exact calculations, useDecimalinstead ofFloat32orFloat64. Floating-point arithmetic can introduce rounding errors.
Decimal
Signed fixed-point numbers that maintain precision through addition, subtraction, and multiplication.
Supported formats: Decimal(P, S), Decimal32(S), Decimal64(S), Decimal128(S).
String
| Keyword | Description |
|---|---|
String | Variable-length string of any size, including null bytes. Equivalent to VARCHAR, BLOB, and CLOB in other database systems. |
FixedString(N) | Fixed-length string of exactly N bytes. More efficient than String when all values have the same byte length. |
Efficient use cases for FixedString:
Binary representation of IPv6 addresses:
FixedString(16)Language codes such as
ru_RUanden_USCurrency codes such as
USDandRUBMD5 hash values:
FixedString(16)SHA-256 hash values:
FixedString(32)
Date and time
| Keyword | Description |
|---|---|
Date | Stores a date as the number of days since 1970-01-01. Takes 2 bytes. Unsigned. Stored without a time zone. |
DateTime | Stores a datetime as the number of seconds since 1970-01-01 00:00:00. Takes 4 bytes. Unsigned. The value range of DateTime is the same as the value range of Date. The minimum value is 1970-01-01 00:00:00. Accurate to seconds; leap seconds are not supported. The time zone is the system time zone of the client or server. |
DateTime64 | Stores both the date and time of a specific point in time. |
Dateis faster thanDateTimeunder most conditions and requires half the storage (2 bytes vs. 4 bytes). The size difference becomes more significant after compression.
Boolean
ClickHouse does not have a native Boolean type. Use UInt8 for Boolean values: 0 for false, 1 for true.
Array
Array(T) — a collection of elements of the same type T. The element type can be any ClickHouse type, including Array.
Avoid multi-dimensional arrays. ClickHouse supports them only partially — multi-dimensional arrays cannot be stored in MergeTree tables.
Tuple
Tuple(T1, T2, ...) — a collection of elements of different types.
Tuples cannot be stored in tables except in memory tables. Use them to group temporary columns in queries with IN expressions or lambda functions.
Domain
The Domain type stores IP addresses in binary format with human-readable input and output:
IPv4 addresses: binary-compatible with
UInt32.IPv6 addresses: binary-compatible with
FixedString(16).
Enumeration
| Keyword | Range | Notes |
|---|---|---|
Enum8 | –128 to 127 | — |
Enum16 | –32,768 to 32,767 | Values can be empty |
Nullable
Nullable(T) — wraps any base type T to allow NULL values. The default value is NULL unless the ClickHouse server configuration specifies otherwise.
Constraints:
Nullablecolumns cannot be included in table indexes.
Nested
Nested — a nested data structure, similar to a table embedded in a cell. Define it with field names and types, using the same syntax as CREATE TABLE. Each row in the outer table can correspond to any number of rows in the nested structure.