常见的postgresql的函数

文章目录

http://www.postgres.cn/docs/10/functions-json.html 命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

// 通过 数据函数来操作 字符串属性
SELECT jsonb_set('{"rtime":"2021-6-15 08:59:44","objid":"001","addition":{"x":114.5379008,"y":30.4835323,"z":0}}','{addition,z}','12')




UPDATE snspdw_position SET content= (jsonb_set(content::jsonb,'{directorytypecode}','"947998009457774691"'::jsonb))

//updata 字符串数据
UPDATE biz_object set confjson = (jsonb_set(confjson::jsonb,'{directorytypecode}','"947998009457774691"'::jsonb)),directorytypecode = '947998009457774691'
where modelcode = '829609839767532682' and objectcode = '948118654552248419';



// 根据 官网提供的实例测试
SELECT jsonb_set('{"a":[null,{"b":[1,2]}]}', '{a,1,b,1000}', jsonb '3', true)

select version()



SELECT jsonb_set('{"rtime":"2021-6-15 08:59:44","objid":"001","addition":{"x":114.5379008,"y":30.4835323,"z":0}}', '$.payFundAcc.addition.z', '3')


{"tel": 13249872314, "name": "Mike", "address": "Guangzhou"} json_set(data,"{address}","Guangzhou")
SELECT jsonb_set('{"tel": 13249872314, "name": "Mike", "address": "Guangzhou"}','{address}','"hahah"')

SELECT jsonb_set('{"rtime":"2021-6-15 08:59:44","objid":"001","addition":{"x":114.5379008,"y":30.4835323,"z":0}}','{addition,z}','12')


SELECT '{"tel": 13249872314, "name": "Mike", "address": "Guangzhou"}'::jsonb