记录pgsql的日常操作

参考链接:https://www.cnblogs.com/panpanwelcome/p/14899488.html

1. 把数据类型的数据转化为多行

unnest(anyarray)

 2. pgsql解析jsonb格式

fileds = [
    {'fileds1': '',
    'fileds2': ''
    },
    {'fileds1': '',
    'fileds2': ''
    },
]

select *  from 
(
select * from table_test limit 10
) as t,
LATERAL jsonb_to_recordset(fileds) x(fileds1 text, fileds2 text) 

3. pgsql多行转化为字符串

array_to_string(array_agg(t.name),',')把多行结果相加

4. 字符串转array

string_to_array(product_season, ','))

参考链接:https://www.postgresql.org/docs/9.4

https://www.postgresql.org/docs/9.4/functions-json.html

posted @ 2022-04-11 17:22  阿磊小哥哥呀  阅读(123)  评论(0编辑  收藏  举报