Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does the @> operator in postgres do?

Tags:

postgresql

I came across a query in postgres here which uses the @> operator on earth objects.

I've searched everywhere, but have come up empty on the meaning of this operator (and likely others like it, eg: @<, etc...).

> is obvious. I also found that @ will take the absolute value of something. So my best guess is this does an absolute greater than comparison of two values?

Is that correct? Is this documented somewhere in the postgres docs? I'm even more curious to understand what the operator does on earth objects.

Thanks!

like image 747
lostdorje Avatar asked May 02 '16 15:05

lostdorje


People also ask

What does @> mean in Postgres?

In general @> is the "contains" operator. It is defined for several data types. arrays: http://www.postgresql.org/docs/current/static/functions-array.html.

What does -> mean in PostgreSQL?

PostgreSQL provides two native operators -> and ->> to help you query JSON data. The operator -> returns JSON object field as JSON. The operator ->> returns JSON object field as text.


1 Answers

In general @> is the "contains" operator.

It is defined for several data types.

  • arrays: http://www.postgresql.org/docs/current/static/functions-array.html
  • range types: http://www.postgresql.org/docs/current/static/functions-range.html
  • geometric types: http://www.postgresql.org/docs/current/static/functions-geometry.html
  • JSON (and JSONB): http://www.postgresql.org/docs/current/static/functions-json.html
like image 147
a_horse_with_no_name Avatar answered Sep 17 '22 22:09

a_horse_with_no_name