JSON/JSONB Operators
Operator | Left Operand Type | Right Operand Type | Return Type | Description | Example | ||
|---|---|---|---|---|---|---|---|
-> | Array-json(b) | int | json(b) | Obtains the array-json element. If the subscript does not exist, NULL is returned. | SELECT '[{"a":"foo"}, {"b":"bar"}, {"c":"baz"}]'::json->2;
?column?
-------------
{"c":"baz"}
(1 row) | ||
-> | object-json(b) | text | json(b) | Obtains the value by a key. If no record exists, NULL is returned. |
| ||
->> | Array-json(b) | int | text | Obtains the array-json element. If the subscript does not exist, NULL is returned. |
| ||
->> | object-json(b) | text | text | Obtains the value by a key. If no record exists, NULL is returned. |
| ||
#> | container-json (b) | text[] | json | Obtains the JSON object in the specified path. If the path does not exist, NULL is returned. NOTE: A DWS object identifier can end with a number sign (#). To avoid ambiguity during the parsing of a#>b, you need to add spaces in front of and behind the operator #>. Otherwise, a parsing error is reported. |
| ||
#>> | container-json (b) | text[] | text | Obtains the JSON object in the specified path. If the path does not exist, NULL is returned. |
|
Operator | Right Operand Type | Return Type | Description | Example | ||
|---|---|---|---|---|---|---|
= | jsonb | bool | Same as the jsonb_eq function, which compares the size of two jsonb files. |
| ||
<> | jsonb | bool | Same as the jsonb_eq function, which compares the size of two jsonb files. |
| ||
< | jsonb | bool | Same as the jsonb_eq function, which compares the size of two jsonb files. |
| ||
> | jsonb | bool | Same as the jsonb_eq function, which compares the size of two jsonb files. |
| ||
<= | jsonb | bool | Same as the jsonb_eq function, which compares the size of two jsonb files. |
| ||
>= | jsonb | bool | Same as the jsonb_eq function, which compares the size of two jsonb files. |
| ||
? | text | bool | Whether the string of the key or element exists at the top layer of the JSON value. |
| ||
?| | text[] | bool | Whether any of these array strings exists as a top-layer key. |
| ||
?& | text[] | bool | Whether all these array strings exist as top-layer keys. |
| ||
<@ | jsonb | bool | Whether all items in the JSON file on the left exist at the top layer of the JSON file on the right. |
| ||
@> | jsonb | bool | Whether all items in the JSON file on the right exist at the top layer of the JSON file on the left. |
| ||
|| | jsonb | jsonb | Combines two JSONB objects into one. |
| ||
- | text | jsonb | Deletes a jsonb object and the specified key-value pair. |
| ||
- | text | jsonb | Deletes a jsonb object and the specified key-value pair. |
| ||
- | int | jsonb | Deletes the element corresponding to the subscript in the JSONB array. |
| ||
#- | text[] | jsonb | Deletes the key-value pair corresponding to the path in the JSONB object. |
|
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.

