PostgreSQL ARRAY_APPEND() function
ARRAY_APPEND() function
The ARRAY_APPEND() function in PostgreSQL is used to add an element to the end of an existing array. This function ensures that the new element is seamlessly included as the last item of the array, maintaining the original order of elements.
Uses of ARRAY_APPEND() Function
- Adding Elements: To add a new element to the end of an existing array.
- Dynamic Array Management: Useful for dynamically building or modifying arrays in queries.
- Data Aggregation: Employed in aggregating data into arrays by appending elements.
- List Manipulations: To perform various list manipulations within database operations.
- Simplifying Queries: Helps simplify queries that need to construct arrays incrementally.
Syntax:
array_append (anyarray, anyelement)
Return Type:
anyarray
PostgreSQL Version: 9.3
Example: PostgreSQL ARRAY_APPEND() function
Code:
SELECT array_append(ARRAY[2,9], 6);
Sample Output:
array_append -------------- {2,9,6} (1 row)
Previous: TRUNC function
Next: ARRAY_CAT 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_append-function.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics