--- title: 'PostgreSQL JSONB Operators' page_title: 'PostgreSQL JSONB Operators' page_description: 'In this tutorial, you will learn about the most commonly used PostgreSQL JSONB operators to process JSONB data effectively.' prev_url: 'https://www.postgresqltutorial.com/postgresql-json-functions/postgresql-jsonb-operators/' ogImage: '' updatedOn: '2024-02-26T11:49:22+00:00' enableTableOfContents: true previousLink: title: 'PostgreSQL jsonb_path_exists() Function' slug: 'postgresql-json-functions/postgresql-jsonb_path_exists' nextLink: title: 'PostgreSQL jsonb_extract_path() Function' slug: 'postgresql-json-functions/postgresql-jsonb_extract_path' --- **Summary**: in this tutorial, you will learn about the PostgreSQL JSONB operators and how to use them to process JSONB data effectively. ## Introduction to PostgreSQL JSONB operators JSONB type allows you to store and query [JSON](../postgresql-tutorial/postgresql-json) data efficiently. JSONB type supports a wide range of operators that help you manipulate and query JSON documents effectively. The following table illustrates the JSONB operators:
| Operator | Syntax | Meaning |
|---|---|---|
-> | jsonb->'key' | Extract the value of the 'key' from a JSON object as a JSONB value |
->> | jsonb->>'key' | Extract the value of the 'key' from a JSON object as a text string |
@> | jsonb @> jsonb → boolean | Return true if the first JSONB value contains the second JSONB value or false otherwise. |
<@ | jsonb <@ jsonb → boolean | Return true if the first JSONB value is contained in the second one or false otherwise. |
? | jsonb ? text → boolean | Return true if a text string exists as a top-level key of a JSON object or as an element of a JSON array or false otherwise. |
?| | jsonb ?| text[] → boolean | Return true if any text string in an array exists as top-level keys of a JSON object or as elements of a JSON array. |
?& | jsonb ?& text[] → boolean | Return true if all text strings in an array exist as top-level keys of a JSON object or as elements of a JSON array. |
|| | jsonb || jsonb → jsonb | Concatenate two JSONB values into one. |
- | jsonb - text → jsonb | Delete a key (and its value) from a JSON object, or matching string value(s) from a JSON array. |
- | jsonb - text[] → jsonb | Delete all matching keys or array elements from the left operand. |
- | jsonb - integer → jsonb | Delete the array element with specified index (negative integers count from the end of the array). |
#- | jsonb #- text[] → jsonb | Delete the field or array element at the specified path. |
@? | jsonb @? jsonpath → boolean | Return true if a JSON path returns any item for the specified JSONB value. |
@@ | jsonb @@ jsonpath → boolean | Evaluate a JSON path against a JSONB value and return a boolean result based on whether the JSON path matches any items within the JSONB value |