PostgreSQL ARRAY_UPPER() function
ARRAY_UPPER() function
The ARRAY_UPPER() function in PostgreSQL returns the upper bound of the specified dimension of an array. This function is useful for determining the highest index in a particular dimension of an array, which can be helpful in various array manipulations and validations.
Uses of the PostgreSQL ARRAY_UPPER() Function
- Determine Upper Bound: Find the highest index of a specific array dimension.
- Validate Array Size: Ensure the array conforms to expected upper bound indices.
- Analyze Array Structures: Understand the indexing scheme of arrays, especially multi-dimensional ones.
- Dynamic Query Adjustments: Adapt operations based on the upper bounds of array dimensions.
Syntax:
array_upper(anyarray, int)
Return Type:
int
PostgreSQL Version: 9.3
Example: PostgreSQL ARRAY_UPPER() function
Code:
SELECT array_upper(ARRAY[1,3,3,5], 1);
Sample Output:
array_upper ------------- 4 (1 row)
Previous: ARRAY_TO_STRING function
Next: STRING_TO_ARRAY 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://w3resource.com/PostgreSQL/postgresql_array_upper-function.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics