0%

postgreSql-json

文章字数:59,阅读全文大约需要1分钟

基本使用

1
2
3
4
5
6
-- 从data表中模糊查询data_content(json)中的code属性
select * from data where data_content::json ->> 'code' like '%123%'

-- ::json转成json
-- ->>接收字符串
-- -->>'code' 字符串类型的code字段

操作符

1
2
3
-> / ->> 取一层
#> / #>> 可取多层: jsonContent::json #>>{a,b} //bbbb
{"a":"{'b':'bbbb'}"}