1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5
>Array Functions and Operators</TITLE
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
12
TITLE="PostgreSQL 9.1beta1 Documentation"
13
HREF="index.html"><LINK
15
TITLE="Functions and Operators"
16
HREF="functions.html"><LINK
18
TITLE="Conditional Expressions"
19
HREF="functions-conditional.html"><LINK
21
TITLE="Aggregate Functions"
22
HREF="functions-aggregate.html"><LINK
25
HREF="stylesheet.css"><META
26
HTTP-EQUIV="Content-Type"
27
CONTENT="text/html; charset=ISO-8859-1"><META
29
CONTENT="2011-04-27T21:20:33"></HEAD
35
SUMMARY="Header navigation table"
47
>PostgreSQL 9.1beta1 Documentation</A
56
TITLE="Conditional Expressions"
57
HREF="functions-conditional.html"
66
TITLE="Functions and Operators"
74
>Chapter 9. Functions and Operators</TD
80
TITLE="Functions and Operators"
89
TITLE="Aggregate Functions"
90
HREF="functions-aggregate.html"
104
NAME="FUNCTIONS-ARRAY"
105
>9.17. Array Functions and Operators</A
109
HREF="functions-array.html#ARRAY-OPERATORS-TABLE"
111
> shows the operators
112
available for array types.
117
NAME="ARRAY-OPERATORS-TABLE"
121
>Table 9-40. Array Operators</B
126
><COL><COL><COL><COL><THEAD
150
>ARRAY[1.1,2.1,3.1]::int[] = ARRAY[1,2,3]</TT
169
>ARRAY[1,2,3] <> ARRAY[1,2,4]</TT
188
>ARRAY[1,2,3] < ARRAY[1,2,4]</TT
207
>ARRAY[1,4,3] > ARRAY[1,2,4]</TT
222
>less than or equal</TD
226
>ARRAY[1,2,3] <= ARRAY[1,2,3]</TT
241
>greater than or equal</TD
245
>ARRAY[1,4,3] >= ARRAY[1,4,3]</TT
264
>ARRAY[1,4,3] @> ARRAY[3,1]</TT
283
>ARRAY[2,7] <@ ARRAY[1,7,4,2,6]</TT
298
>overlap (have elements in common)</TD
302
>ARRAY[1,4,3] && ARRAY[2,1]</TT
317
>array-to-array concatenation</TD
321
>ARRAY[1,2,3] || ARRAY[4,5,6]</TT
336
>array-to-array concatenation</TD
340
>ARRAY[1,2,3] || ARRAY[[4,5,6],[7,8,9]]</TT
345
>{{1,2,3},{4,5,6},{7,8,9}}</TT
355
>element-to-array concatenation</TD
359
>3 || ARRAY[4,5,6]</TT
374
>array-to-element concatenation</TD
378
>ARRAY[4,5,6] || 7</TT
390
> Array comparisons compare the array contents element-by-element,
391
using the default B-tree comparison function for the element data type.
392
In multidimensional arrays the elements are visited in row-major order
393
(last subscript varies most rapidly).
394
If the contents of two arrays are equal but the dimensionality is
395
different, the first difference in the dimensionality information
396
determines the sort order. (This is a change from versions of
400
> prior to 8.2: older versions would claim
401
that two arrays with the same contents were equal, even if the
402
number of dimensions or subscript ranges were different.)
408
> for more details about array operator
413
HREF="functions-array.html#ARRAY-FUNCTIONS-TABLE"
415
> shows the functions
416
available for use with array types. See <A
420
for more information and examples of the use of these functions.
425
NAME="ARRAY-FUNCTIONS-TABLE"
429
>Table 9-41. Array Functions</B
434
><COL><COL><COL><COL><COL><THEAD
472
>append an element to the end of an array</TD
476
>array_append(ARRAY[1,2], 3)</TT
507
>concatenate two arrays</TD
511
>array_cat(ARRAY[1,2,3], ARRAY[4,5])</TT
539
>returns the number of dimensions of the array</TD
543
>array_ndims(ARRAY[[1,2,3], [4,5,6]])</TT
571
>returns a text representation of array's dimensions</TD
575
>array_dims(ARRAY[[1,2,3], [4,5,6]])</TT
613
>returns an array initialized with supplied value and
614
dimensions, optionally with lower bounds other than 1</TD
618
>array_fill(7, ARRAY[3], ARRAY[2])</TT
649
>returns the length of the requested array dimension</TD
653
>array_length(array[1,2,3], 1)</TT
684
>returns lower bound of the requested array dimension</TD
688
>array_lower('[0:2]={1,2,3}'::int[], 1)</TT
719
>append an element to the beginning of an array</TD
723
>array_prepend(1, ARRAY[2,3])</TT
737
>array_to_string</CODE
760
>concatenates array elements using supplied delimiter and
761
optional null string</TD
765
>array_to_string(ARRAY[1, 2, 3, NULL, 5], ',', '*')</TT
796
>returns upper bound of the requested array dimension</TD
800
>array_upper(ARRAY[1,8,3,7], 1)</TT
814
>string_to_array</CODE
837
>splits string into array elements using supplied delimiter and
838
optional null string</TD
842
>string_to_array('xx~^~yy~^~zz', '~^~', 'yy')</TT
867
>setof anyelement</TT
870
>expand an array to a set of rows</TD
874
>unnest(ARRAY[1,2])</TT
878
CLASS="LITERALLAYOUT"
889
>string_to_array</CODE
890
>, if the delimiter parameter is
891
NULL, each character in the input string will become a separate element in
892
the resulting array. If the delimiter is an empty string, then the entire
893
input string is returned as a one-element array. Otherwise the input
894
string is split at each occurrence of the delimiter string.
899
>string_to_array</CODE
900
>, if the null-string parameter
901
is omitted or NULL, none of the substrings of the input will be replaced
905
>array_to_string</CODE
906
>, if the null-string parameter
907
is omitted or NULL, any null elements in the array are simply skipped
908
and not represented in the output string.
917
> There are two differences in the behavior of <CODE
919
>string_to_array</CODE
921
from pre-9.1 versions of <SPAN
925
First, it will return an empty (zero-element) array rather than NULL when
926
the input string is of zero length. Second, if the delimiter string is
927
NULL, the function splits the input into individual characters, rather
928
than returning NULL as before.
934
HREF="functions-aggregate.html"
936
> about the aggregate
940
> for use with arrays.
948
SUMMARY="Footer navigation table"
959
HREF="functions-conditional.html"
977
HREF="functions-aggregate.html"
987
>Conditional Expressions</TD
993
HREF="functions.html"
1001
>Aggregate Functions</TD
b'\\ No newline at end of file'