array_ndims()

A function returning the number of dimensions of an array

array_ndims() is a system function returning the number of dimensions of an array.

array_ndims() was added in PostgreSQL 8.4.

Usage

array_ndims ( anyarray ) → integer

Change history

Examples

Basic usage example for array_ndims():

postgres=# SELECT array_ndims(ARRAY[1,2,3]);
 array_ndims 
-------------
           1
(1 row)

With a multi-dimensional array:

postgres=# SELECT array_ndims(ARRAY[ [1,2,3],[4,5,6] ]);
 array_ndims 
-------------
           2
(1 row)

Categories

Arrays, System function

See also

array_dims(), array_lower(), array_upper(), cardinality()