- ::双冒号表示类型转换
1 | SELECT 1::INTEGER; |
Operator | Right Operand Type | Description | Example | ||
---|---|---|---|---|---|
@> |
jsonb |
Does the left JSON value contain within it the right value? | '{"a":1, "b":2}'::jsonb @> '{"b":2}'::jsonb |
||
<@ |
jsonb |
Is the left JSON value contained within the right value? | '{"b":2}'::jsonb <@ '{"a":1, "b":2}'::jsonb |
||
? |
text |
Does the key/element string exist within the JSON value? | '{"a":1, "b":2}'::jsonb ? 'b' |
||
`? | ` | text[] |
Do any of these key/element strings exist? | `’{“a”:1, “b”:2, “c”:3}’::jsonb ? | array[‘b’, ‘c’]` |
?& |
text[] |
Do all of these key/element strings exist? | '["a", "b"]'::jsonb ?& array['a', 'b'] |
1 | SELECT '{"模型分类": ["人物", "道具"], "模型面数": ["低模"]}'::jsonb->'模型分类' @> '["人物","道具"]'; |
参考资料:
9.15. JSON Functions and Operators
JSON Functions and Operators
8.14. JSON Types
Querying JSON in Postgres
PostgreSQL 9.4.4 中文手册
PostgreSQL 9.4.4 中文手册 章 8. 数据类型
Array Functions and Operators