PostgreSQL array_lower() Function

The PostgreSQL array_lower() function returns the starting subscript of a specified array dimension.

array_lower() Syntax

Here is the syntax of the PostgreSQL array_lower() function:

array_lower(array, dimension) -> integer

Parameters

array

Required. The array.

dimension

Required. The dimension of the array, that is an integer.

Return value

The PostgreSQL array_lower() function returns an integer that is the starting subscript of the specified dimension in the specified array.

If you specify a dimension that does not exist in the array, the function will return NULL.

array_lower() Examples

one-dimensional array

This example shows how to use a PostgreSQL array_lower() function to return the starting subscript of a one-dimensional array.

SELECT array_lower(ARRAY[0, 1, 2], 1);
 array_lower
-------------
           1

This means that the starting subscript of [0, 1, 2] is 1.

SELECT array_lower('[3:7]={1,1,1,1,1}'::integer[], 1);
 array_lower
-------------
           3

This means that the starting subscript of [3:7]={1,1,1,1,1} is 3.

Multidimensional Arrays

For a multidimensional array, you can get the starting subscript of an array dimension. for example:

SELECT array_lower('[2:4][2:3]={{1,1},{1,1},{1,1}}'::integer[], 2);
 array_lower
-------------
           2

This means that the starting index of the second demension of [2:4][2:3]={{1,1},{1,1},{1,1}} is 2.