What is the second argument in array_length() func

2019-06-18 13:11发布

问题:

Postgresql 9.4 has functions for array. One of them is array_length(anyarray, int). It get two argumetns.

What is the second argument? In all examples it has value 1. But nowhere says what it is.

回答1:

That's array's dimension.

Consider an example with a 2D array 3×2:

array_length(array[[1, 2], [3, 4], [5, 6]], 1) ---> 3
array_length(array[[1, 2], [3, 4], [5, 6]], 2) ---> 2

The size of the first dimension is 3; the size of the second dimension is 2.