postgres 常用方言语法记录
postgres
解析 postgres 里的json
select (supplier_sku_info -> 'type') :: int8 from table;
- 也可以这么写
select supplier_sku_info @> cast('{"type": 1}' as jsonb) from table;
- 通过-> 箭头 提取json 中的参数,默认返回json 格式 所以需要用 转换为 需要的类型
- :: 为postgres 方言
select 1 from table where (supplier_sku_info -> 'types') :: varchar is null ;
- 对于取出的值不存在这个key 通过is null 去判读即可。
版权声明:
本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自
幽林萌逐的blog!
喜欢就支持一下吧