TABLE

id p1
1 888
2 888
3 888
4 888
5 888
6 888
select array[1,2,3] <@ (select array_agg(id) from mid where p1=888);
// result: true
select array[1,2,3,7] <@ (select array_agg(id) from mid where p1=888);
// result: false
select array[8,9,10] <@ (select array_agg(id) from mid where p1=888);
// result: false
select array[1,2] <@ (select array_agg(id) from mid where p1=888);
// result: true

ARRAY常用操作符

Operator Description Example Result
= equal ARRAY[1.1,2.1,3.1]::int[] = ARRAY[1,2,3] T
<> not equal ARRAY[1,2,3] <> ARRAY[1,2,4] T
< less than ARRAY[1,2,3] < ARRAY[1,2,4] T
> greater than ARRAY[1,4,3] > ARRAY[1,2,4] T
<= less than or equal ARRAY[1,2,3] <= ARRAY[1,2,3] T
>= greater than or equal ARRAY[1,4,3] >= ARRAY[1,4,3] T
@> contains ARRAY[1,4,3] @> ARRAY[3,1] T
<@ is contained by ARRAY[2,7] <@ ARRAY[1,7,4,2,6] T
&& overlap (have elements in common) ARRAY[1,4,3] && ARRAY[2,1] T
|| array-to-array concatenation ARRAY[1,2,3] || ARRAY[4,5,6] {1,2,3,4,5,6}
|| array-to-array concatenation ARRAY[1,2,3] || ARRAY[[4,5,6],[7,8,9]] {{1,2,3},{4,5,6},{7,8,9}}
|| element-to-array concatenation 3 || ARRAY[4,5,6] {3,4,5,6}
|| array-to-element concatenation ARRAY[4,5,6] || 7 {4,5,6,7}