Collection Types

Collection types are special generic types used to group homogeneous or heterogeneous data.

type
array

Arrays represent a one-dimensional homogeneous ordered list.

Array indexing starts at zero.

With the exception of other array types, any type can be used as an array element type.

An array type is created implicitly when an array constructor is used:

Copy
db> 
SELECT [1, 2];
{[1, 2]}

The syntax of an array type declaration can be found in this section.

See also the list of standard array functions and generic functions such as len().

type
tuple

A tuple type is a heterogeneous sequence of other types.

Tuple elements can optionally have names, in which case the tuple is called a named tuple.

Any type can be used as a tuple element type.

A tuple type is created implicitly when a tuple constructor is used:

Copy
db> 
SELECT ('foo', 42);
{('foo', 42)}

Two tuples are equal if all of their elements are equal and in the same order. Note that element names in named tuples are not significant for comparison:

Copy
db> 
SELECT (1, 2, 3) = (a := 1, b := 2, c := 3);
{true}

The syntax of a tuple type declaration can be found in this section.

Collection type introspection.

Light
Dark
System