+ |
+
+
+ array_append ( anyarray, anyelement )
+ anyarray
+
+ Appends an element to the end of an array (same as
+ the anyarray || anyelement
+ operator).
+
+ array_append(ARRAY[1,2], 3)
+ {1,2,3}
+
+
- In array_positions, NULL is returned
- only if the array is NULL; if the value is not found in
- the array, an empty array is returned instead.
-
+ |
+
+
+ array_cat ( anyarray, anyarray )
+ anyarray
+
+ Concatenates two arrays (same as
+ the anyarray || anyarray
+ operator).
+
+ array_cat(ARRAY[1,2,3], ARRAY[4,5])
+ {1,2,3,4,5}
+
+
- In string_to_array, if the delimiter parameter is
- NULL, each character in the input string will become a separate element in
- the resulting array. If the delimiter is an empty string, then the entire
- input string is returned as a one-element array. Otherwise the input
- string is split at each occurrence of the delimiter string.
-
+ |
+
+
+ array_dims ( anyarray )
+ text
+
+ Returns a text representation of the array's dimensions.
+
+ array_dims(ARRAY[[1,2,3], [4,5,6]])
+ [1:2][1:3]
+
+
- In string_to_array, if the null-string parameter
- is omitted or NULL, none of the substrings of the input will be replaced
- by NULL.
- In array_to_string, if the null-string parameter
- is omitted or NULL, any null elements in the array are simply skipped
- and not represented in the output string.
-
+ |
+
+
+ array_fill ( anyelement, integer[]
+ , integer[] )
+ anyarray
+
+ Returns an array filled with copies of the given value, having
+ dimensions of the lengths specified by the second argument.
+ The optional third argument supplies lower-bound values for each
+ dimension (which default to all 1).
+
+ array_fill(11, ARRAY[2,3])
+ {{11,11,11},{11,11,11}}
+
+ array_fill(7, ARRAY[3], ARRAY[2])
+ [2:4]={7,7,7}
+
+
+
+ |
+
+
+ array_length ( anyarray, integer )
+ integer
+
+ Returns the length of the requested array dimension.
+
+ array_length(array[1,2,3], 1)
+ 3
+
+
+
+ |
+
+
+ array_lower ( anyarray, integer )
+ integer
+
+ Returns the lower bound of the requested array dimension.
+
+ array_lower('[0:2]={1,2,3}'::integer[], 1)
+ 0
+
+
+
+ |
+
+
+ array_ndims ( anyarray )
+ integer
+
+ Returns the number of dimensions of the array.
+
+ array_ndims(ARRAY[[1,2,3], [4,5,6]])
+ 2
+
+
+
+ |
+
+
+ array_position ( anyarray, anyelement , integer )
+ integer
+
+ Returns the subscript of the first occurrence of the second argument
+ in the array, or NULL if it's not present.
+ If the third argument is given, the search begins at that subscript.
+ The array must be one-dimensional.
+ Comparisons are done using IS NOT DISTINCT FROM
+ semantics, so it is possible to search for NULL.
+
+ array_position(ARRAY['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'], 'mon')
+ 2
+
+
+
+ |
+
+
+ array_positions ( anyarray, anyelement )
+ integer[]
+
+ Returns an array of the subscripts of all occurrences of the second
+ argument in the array given as first argument.
+ The array must be one-dimensional.
+ Comparisons are done using IS NOT DISTINCT FROM
+ semantics, so it is possible to search for NULL.
+ NULL is returned only if the array
+ is NULL; if the value is not found in the array, an
+ empty array is returned.
+
+ array_positions(ARRAY['A','A','B','A'], 'A')
+ {1,2,4}
+
+
+
+ |
+
+
+ array_prepend ( anyelement, anyarray )
+ anyarray
+
+ Prepends an element to the beginning of an array (same as
+ the anyelement || anyarray
+ operator).
+
+ array_prepend(1, ARRAY[2,3])
+ {1,2,3}
+
+
+
+ |
+
+
+ array_remove ( anyarray, anyelement )
+ anyarray
+
+ Removes all elements equal to the given value from the array.
+ The array must be one-dimensional.
+ Comparisons are done using IS NOT DISTINCT FROM
+ semantics, so it is possible to remove NULLs.
+
+ array_remove(ARRAY[1,2,3,2], 2)
+ {1,3}
+
+
+
+ |
+
+
+ array_replace ( anyarray, anyelement, anyelement )
+ anyarray
+
+ Replaces each array element equal to the second argument with the
+ third argument.
+
+ array_replace(ARRAY[1,2,5,4], 5, 3)
+ {1,2,3,4}
+
+
+
+ |
+
+
+ array_to_string ( array anyarray, delimiter text , null_string text )
+ text
+
+ Converts each array element to its text representation, and
+ concatenates those separated by
+ the delimiter string.
+ If null_string is given and is
+ not NULL, then NULL array
+ entries are represented by that string; otherwise, they are omitted.
+
+ array_to_string(ARRAY[1, 2, 3, NULL, 5], ',', '*')
+ 1,2,3,*,5
+
+
+
+ |
+
+
+ array_upper ( anyarray, integer )
+ integer
+
+ Returns the upper bound of the requested array dimension.
+
+ array_upper(ARRAY[1,8,3,7], 1)
+ 4
+
+
+
+ |
+
+
+ cardinality ( anyarray )
+ integer
+
+ Returns the total number of elements in the array, or 0 if the array
+ is empty.
+
+ cardinality(ARRAY[[1,2],[3,4]])
+ 4
+
+
+
+ |
+
+
+ string_to_array ( string text, delimiter text , null_string text )
+ text[]
+
+ Splits the string at occurrences
+ of delimiter and forms the remaining data
+ into a text array.
+ If delimiter is NULL,
+ each character in the string will become a
+ separate element in the array.
+ If delimiter is an empty string, then
+ the string is treated as a single field.
+ If null_string is supplied and is
+ not NULL, fields matching that string are converted
+ to NULL entries.
+
+ string_to_array('xx~~yy~~zz', '~~', 'yy')
+ {xx,NULL,zz}
+
+
+
+ |
+
+
+ unnest ( anyarray )
+ setof anyelement
+
+ Expands an array to a set of rows.
+
+ unnest(ARRAY[1,2])
+
+ 1
+ 2
+
+ (2 rows in result)
+
+
+
+ |
+ unnest ( anyarray, anyarray , ... )
+ setof anyelement, anyelement [, ... ]
+
+ Expands multiple arrays (possibly of different data types) to a set of
+ rows. If the arrays are not all the same length then the shorter ones
+ are padded with NULLs. This is only allowed in a
+ query's FROM clause; see .
+
+ select * from unnest(ARRAY[1,2], ARRAY['foo','bar','baz']) as x(a,b)
+
+ a | b
+---+-----
+ 1 | foo
+ 2 | bar
+ | baz
+
+
+
+