说明
Clickhouse是使用C/C++写的,数据类型和C语言的类型相关。
官网:https://clickhouse.com/docs/en/sql-reference/data-types/
整形
整形区分为有符号和无符号类型的整数。
有符号类型
整型范围(-2^n-1~2^n-1 -1): 8位=1字节
| MySQL | Hive | Clickhouse | 大小(字节) | 数据范围 |
|---|---|---|---|---|
| tinyint | tinyint | Int8 | 1 | [-128 : 127] |
| smallint | smallint | Int16 | 2 | [-32768 : 32767] |
| int | int | Int32 | 3 | [-2147483648 : 2147483647] |
| bigint | bigint | Int64 | 4 | [-9223372036854775808 : 9223372036854775807] |
另外还有 Int128、Int256
无符号类型
无符号类型:范围 0~2^n-1
| MySQL | Clickhouse | 大小(字节) | 数据范围 |
|---|---|---|---|
| Tinyint unsigned | UInt8 | 1 | [0 : 255] |
| smallint unsigned | UInt16 | 2 | [0 : 65535] |
| Int unsigned | UInt32 | 3 | [0 : 4294967295] |
| Bigint unsigned | UInt64 | 4 | [0 : 18446744073709551615] |
另外还有 UInt128、UInt256