📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

ARRAY



Builds an array literal from the supplied expressions. Each argument is evaluated and stored in order. All elements must be castable to a common type.

Syntax

ARRAY(<expr1>, <expr2>, ... )

Return Type

ARRAY

Examples

SELECT ARRAY(1, 2, 3) AS arr_int; ┌─────────┐ │ arr_int │ ├─────────┤ │ [1,2,3] │ └─────────┘
SELECT ARRAY('alpha', UPPER('beta')) AS arr_text; ┌───────────┐ │ arr_text │ ├───────────┤ │ ["alpha","BETA"] │ └───────────┘
SELECT ARRAY(1, NULL, 3) AS arr_with_null; ┌────────────────┐ │ arr_with_null │ ├────────────────┤ │ [1,NULL,3] │ └────────────────┘

Was this page helpful?