STRING_TO_ARRAY
Splits a string on a specified delimiter character and returns an array. The string must be bounded by brackets. The output does not include the "ARRAY" keyword.
The delimiter must be a single character. If you specify a multi-character string, the results are undefined.
This function returns array elements as strings. The function does not support casting to other types; instead, cast the elements to other types when operating on the returned array.
Behavior
Syntax
STRING_TO_ARRAY(string,delim_char)
Supported Data Types
- STRING/VARCHAR
Examples
=> SELECT STRING_TO_ARRAY('[1,3,5]', ','); STRING_TO_ARRAY ----------------- ["1","3","5"] (1 row) => SELECT STRING_TO_ARRAY('[t|t|f|t]','|'); STRING_TO_ARRAY ----------------- ["t","t","f","t"] (1 row) => SELECT STRING_TO_ARRAY('[]',','); STRING_TO_ARRAY ----------------- [null] (1 row)