2017-02-17 2 views

Antwort

0

Aktualisieren Sie die jsonb Spalte die concatenate operator ||, z.B .:

create table example(id int, js jsonb); 
insert into example values 
(1, '{"id": "3", "username": "abcdef"}'); 

update example 
set js = js || jsonb_build_object('id', (js->>'id')::int) 
returning *; 

id |    js     
----+--------------------------------- 
    1 | {"id": 3, "username": "abcdef"} 
(1 row) 
mit
0
select json_build_object('id',CAST(j->>'id' AS NUMERIC),'username',j->>'username')::jsonb from (
    select '{"id" : "3", "username" : "abcdef"}' :: jsonb AS j 
)t 
Verwandte Themen