postgresql jsonb 拼接

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u011944141/article/details/82912365

postgresql jsonb 拼接

#替换
select '{"name":"abc"}'::jsonb || '{"name":"aaa"}'::jsonb as name;
      name       
-----------------
 {"name": "aaa"}
(1 row)

#新增 或 合并
select '{"name":"abc"}'::jsonb || '{"age":"18"}'::jsonb as person;
            person            
------------------------------
 {"age": "18", "name": "abc"}
(1 row)

#extend 字段为jsonb类型
update 
	crm.test 
set 
	extend = extend::jsonb || ('{"name":"' || (extend->>'arrive') || '"}')::jsonb 
where 
	id = 1;



猜你喜欢

转载自blog.csdn.net/u011944141/article/details/82912365