Pemilihan tipe data yang tepat untuk bidang tabel meningkatkan performa database dan efisiensi penyimpanan, sekaligus menjaga integritas data, keterbacaan, keamanan, serta konsistensi. Topik ini menjelaskan tipe data yang didukung oleh ApsaraDB for SelectDB. Anda juga dapat menjalankan pernyataan SHOW DATA TYPES; untuk melihat semua tipe data yang didukung oleh SelectDB.
Numeric types
Type name | Bytes | Description |
BOOLEAN | 1 | Nilai Boolean. 0: false 1: true |
TINYINT | 1 | Bilangan bulat bertanda. Rentang nilai: [-128, 127] |
SMALLINT | 2 | Bilangan bulat bertanda. Rentang nilai: [-32768, 32767] |
INT | 4 | Bilangan bulat bertanda. Rentang nilai: [-2147483648, 2147483647] |
BIGINT | 8 | Bilangan bulat bertanda. Rentang nilai: [-9223372036854775808, 9223372036854775807] |
LARGEINT | 16 | Bilangan bulat bertanda. Rentang nilai: [-2^127 + 1 ~ 2^127 - 1] |
FLOAT | 4 | Bilangan titik mengambang. Rentang nilai: [-3.4×10^38 ~ 3.4×10^38] |
DOUBLE | 8 | Bilangan titik mengambang. Rentang nilai: [-1.79×10^308 ~ 1.79×10^308] |
DECIMAL | 4/8/16 | Bilangan titik tetap berpresisi tinggi. Format definisi:
|
Date types
Type name | Bytes | Description |
DATE | 16 | Date type. Value range: ['0000-01-01', '9999-12-31'] Default output format: |
DATETIME | 16 | Date and time type. Definition format: Catatan P:
Value range: ['0000-01-01 00:00:00[.000000]', '9999-12-31 23:59:59[.999999]'] Default output format: |
String types
Type name | Bytes | Description |
CHAR | M | Fixed-length string. Definition format: Catatan M represents the byte length of the fixed-length string. Storage size: 1 to 255 bytes. |
VARCHAR | Variable | Variable-length string. Definition format: Catatan
Storage size: 1 to 65533 bytes. |
STRING | Variable | Variable-length string. Default minimum storage size: 1048576 bytes (1 MB) Maximum storage size: 2147483643 bytes (2 GB) Penting
|
Semi-structured types
Type name | Bytes | Description |
ARRAY | Variable | An array of elements of type T. Definition format: ARRAY<T> Catatan
Usage notes:
|
MAP | Variable | A map of key-value pairs of types K and V. Definition format: MAP<K,V> Catatan Supported types for K and V: Usage notes:
|
STRUCT | Variable | A struct composed of multiple fields, which can also be viewed as a collection of columns. Definition format: STRUCT<field_name:field_type, ... > Catatan
Usage notes:
|
JSON | Variable | Stored in binary JSON format. Access internal fields using JSON functions. Default supported storage size: 1048576 bytes (1 MB) Maximum supported storage size: 2147483643 bytes (2 GB) Catatan You can adjust its storage size using the parameter |
VARIANT | Variable | A dynamic data type designed for semi-structured data such as JSON. It accepts any valid JSON input and automatically splits JSON fields into sub-columns for improved storage efficiency and query analysis performance. VARIANT is especially useful for handling complex nested structures that may change over time. For more information, see VARIANT. Penting VARIANT is only supported in SelectDB kernel version |
Aggregation types
Type name | Bytes | Description |
HLL | Variable | HLL provides approximate deduplication. It performs better than Count Distinct on large datasets. Usage notes:
|
BITMAP | Variable | Used for exact deduplication, such as UV counting and audience segmentation. Usage notes:
|
QUANTILE_STATE | Variable | Used to compute approximate quantiles. During data ingestion, pre-aggregation is performed on different Values with the same Key.
Usage notes:
|
AGG_STATE | Variable | Aggregate functions Used to accelerate aggregation computations. It must be used together with the Usage notes:
|
IP types
Tipe data berikut hanya didukung di SelectDB kernel versi 4.0.0 atau yang lebih baru. Jika instance Anda menjalankan versi sebelumnya, Anda harus melakukan upgrade kernel. Untuk informasi selengkapnya, lihat Upgrade kernel version.
Type name | Bytes | Description |
IPv4 | 4 bytes | Stores IPv4 addresses as 4-byte binary values. Use with ipv4_* family functions. |
IPv6 | 16 bytes | Stores IPv6 addresses as 16-byte binary values. Use with ipv6_* family functions. |