9.20. Range/Multirange Functions and Operators (original) (raw)

Operator Description Example(s)
anymultirange @> anymultirange → boolean Does the first multirange contain the second? '{[2,4)}'::int4multirange @> '{[2,3)}'::int4multirange → t
anymultirange @> anyrange → boolean Does the multirange contain the range? '{[2,4)}'::int4multirange @> int4range(2,3) → t
anymultirange @> anyelement → boolean Does the multirange contain the element? '{[2011-01-01,2011-03-01)}'::tsmultirange @> '2011-01-10'::timestamp → t
anyrange @> anymultirange → boolean Does the range contain the multirange? '[2,4)'::int4range @> '{[2,3)}'::int4multirange → t
anymultirange <@ anymultirange → boolean Is the first multirange contained by the second? '{[2,4)}'::int4multirange <@ '{[1,7)}'::int4multirange → t
anymultirange <@ anyrange → boolean Is the multirange contained by the range? '{[2,4)}'::int4multirange <@ int4range(1,7) → t
anyrange <@ anymultirange → boolean Is the range contained by the multirange? int4range(2,4) <@ '{[1,7)}'::int4multirange → t
anyelement <@ anymultirange → boolean Is the element contained by the multirange? 4 <@ '{[1,7)}'::int4multirange → t
anymultirange && anymultirange → boolean Do the multiranges overlap, that is, have any elements in common? '{[3,7)}'::int8multirange && '{[4,12)}'::int8multirange → t
anymultirange && anyrange → boolean Does the multirange overlap the range? '{[3,7)}'::int8multirange && int8range(4,12) → t
anyrange && anymultirange → boolean Does the range overlap the multirange? int8range(3,7) && '{[4,12)}'::int8multirange → t
anymultirange << anymultirange → boolean Is the first multirange strictly left of the second? '{[1,10)}'::int8multirange << '{[100,110)}'::int8multirange → t
anymultirange << anyrange → boolean Is the multirange strictly left of the range? '{[1,10)}'::int8multirange << int8range(100,110) → t
anyrange << anymultirange → boolean Is the range strictly left of the multirange? int8range(1,10) << '{[100,110)}'::int8multirange → t
anymultirange >> anymultirange → boolean Is the first multirange strictly right of the second? '{[50,60)}'::int8multirange >> '{[20,30)}'::int8multirange → t
anymultirange >> anyrange → boolean Is the multirange strictly right of the range? '{[50,60)}'::int8multirange >> int8range(20,30) → t
anyrange >> anymultirange → boolean Is the range strictly right of the multirange? int8range(50,60) >> '{[20,30)}'::int8multirange → t
anymultirange &< anymultirange → boolean Does the first multirange not extend to the right of the second? '{[1,20)}'::int8multirange &< '{[18,20)}'::int8multirange → t
anymultirange &< anyrange → boolean Does the multirange not extend to the right of the range? '{[1,20)}'::int8multirange &< int8range(18,20) → t
anyrange &< anymultirange → boolean Does the range not extend to the right of the multirange? int8range(1,20) &< '{[18,20)}'::int8multirange → t
anymultirange &> anymultirange → boolean Does the first multirange not extend to the left of the second? '{[7,20)}'::int8multirange &> '{[5,10)}'::int8multirange → t
anymultirange &> anyrange → boolean Does the multirange not extend to the left of the range? '{[7,20)}'::int8multirange &> int8range(5,10) → t
anyrange &> anymultirange → boolean Does the range not extend to the left of the multirange? int8range(7,20) &> '{[5,10)}'::int8multirange → t
anymultirange -|- anymultirange → boolean Are the multiranges adjacent? '{[1.1,2.2)}'::nummultirange -
anymultirange -|- anyrange → boolean Is the multirange adjacent to the range? '{[1.1,2.2)}'::nummultirange -
anyrange -|- anymultirange → boolean Is the range adjacent to the multirange? numrange(1.1,2.2) -
anymultirange + anymultirange → anymultirange Computes the union of the multiranges. The multiranges need not overlap or be adjacent. '{[5,10)}'::nummultirange + '{[15,20)}'::nummultirange → {[5,10), [15,20)}
anymultirange * anymultirange → anymultirange Computes the intersection of the multiranges. '{[5,15)}'::int8multirange * '{[10,20)}'::int8multirange → {[10,15)}
anymultirange - anymultirange → anymultirange Computes the difference of the multiranges. '{[5,20)}'::int8multirange - '{[10,15)}'::int8multirange → {[5,10), [15,20)}