PostgreSQL ARRAY_NDIMS() function
ARRAY_NDIMS() function
The ARRAY_NDIMS() function in PostgreSQL returns the number of dimensions of a given array. This function is useful for determining the complexity or structure of an array, especially when dealing with multi-dimensional arrays.
Uses of the PostgreSQL ARRAY_NDIMS() Function
- Determine Array Complexity: Find out how many dimensions an array has.
- Validate Array Structure: Check if an array meets the required dimensional criteria.
- Analyze Data: Understand the structure of multi-dimensional arrays for data processing.
- Dynamic Queries: Adapt queries based on the dimensionality of arrays.
Syntax:
array_ndims(anyarray)
Return Type:
int
PostgreSQL Version: 9.3
Example: PostgreSQL ARRAY_NDIMS() function
Sample Output:
array_ndims ------------- 2 (1 row)
Previous: ARRAY_CAT function
Next: ARRAY_DIMS function