看看我的 JSONB 字段
select internet_address from resporg_account_ids where id=3
=> [{"zone": "us-central1", "address": "127.0.0.1", "reserve": true}, {"zone": "us-east1", "address": "127.0.0.10", "reserve": true}
]
相关jsonb查询
select * from resporg_account_ids where internet_address <@ '[{"zone": "us-central1", "address": "127.0.0.1", "reserve": true}]'::jsonb;
和这个
select * from resporg_account_ids where internet_address <@ '{"zone": "us-central1", "address": "127.0.0.1", "reserve": true}'::jsonb;
而且我在输出控制台中看不到任何结果。
另外,我想根据单个键查询它...
喜欢
select * from resporg_account_ids where internet_address->>address="127.0.0.1" and internet_address->>reserve=true
最后,
jsondb=# select version();
version
---------------------------------------------------------------------------------------------------------------
PostgreSQL 9.5.10 on x86_64-apple-darwin17.2.0, compiled by Apple LLVM version 9.0.0 (clang-900.0.38), 64-bit
(1 row)
笔记:
第 1 部分:已解决感谢@mroman 指出这一点。