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
SELECT array_ndims(ARRAY[[1,2,3], [4,5,6]]);
Sample Output:
array_ndims ------------- 2 (1 row)
Previous: ARRAY_CAT function
Next: ARRAY_DIMS function
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/PostgreSQL/postgresql_array_ndims-function.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics