Types for arrays
-
BIGINT[]-
Alias:
INTEGER[]
-
-
VARCHAR[]-
Aliases:
CHAR[],BPCHAR[],STRING[],TEXT[]
-
-
BOOL[]-
Aliases:
BOOLEAN[]
-
Description
The BIGINT[], VARCHAR[], and BOOL[] types are used to store arrays of integers, arrays of strings, and arrays of boolean values, respectively.
| The length of arrays in the same column of the table may not be the same. |
Arrays can be used to store vectors such as embeddings (vector representations) of texts or images.
Examples
Create a table array_table and insert values of type VARCHAR and type VARCHAR[] into it:
CREATE TABLE array_table(text_column VARCHAR, array_column VARCHAR[]);
INSERT INTO array_table VALUES
('I love Tengri', ['I','love', 'Tengri']),
('I adore Tengri', ['I','adore', 'Tengri']);
SELECT * FROM array_table;
+----------------+------------------+
| text_column | array_column |
+----------------+------------------+
| I love Tengri | {I,love,Tengri} |
+----------------+------------------+
| I adore Tengri | {I,adore,Tengri} |
+----------------+------------------+
Note that in program output, arrays are displayed with curly braces {} and text values in them — without quotes.
Now let’s create an array_table table with columns of type BIGINT and BIGINT[] and insert numeric values and arrays of numbers into it:
CREATE TABLE array_table(number_column BIGINT, array_column BIGINT[]);
INSERT INTO array_table VALUES
(2025, [2,0,2,5]),
(0025, [0,0,2,5]);
SELECT * FROM array_table;
+---------------+--------------+
| number_column | array_column |
+---------------+--------------+
| 2025 | {2,0,2,5} |
+---------------+--------------+
| 25 | {0,0,2,5} |
+---------------+--------------+
Note that the numeric value 0025 in the programme output is cast to the normal form 25, and arrays in the programme output are shown through curly braces {}.