jsonb 应用 update tjsonb set fjsonb fjsonb '{"col2":"teledbupdate"}'::jsonb where id3; UPDATE 1 teledb select from tjsonb; id fjsonb + 2 {"col1": 1, "col2": "teledb", "col3": "pgxz"} 1 {"col1": 1, "col2": "teledb", "col3": "pgxz"} 3 {"col1": 1, "col2": "teledbupdate"} (3 rows) 删除某个键。 plaintext teledb update tjsonb set fjsonb fjsonb 'col3'; UPDATE 3 teledb select from tjsonb; id fjsonb + 2 {"col1": 1, "col2": "teledb"} 1 {"col1": 1, "col2": "teledb"} 3 {"col1": 1, "col2": "teledbupdate"} (3 rows) jsonbset()函数更新数据 plaintext jsonbset(target jsonb, path text[], newvalue jsonb, [createmissing boolean]) 说明 target指要更新的数据源,path指路径,newvalue指更新后的键值,createmissing值为true表示如果键不存在则添加,createmissing值为false表示如果键不存在则不添加。 plaintext teledb update tjsonb set fjsonb jsonbset( fjsonb , '{col}' , '"pgxz"' , true ) where id1; UPDATE 1 teledb select from tjsonb; id fjsonb + 2 {"col1": 1, "col2": "teledb"} 3 {"col1": 1, "col2": "teledbupdate"} 1 {"col": "pgxz", "col1": 1, "col2": "teledb"} (3 rows) teledb update tjsonb set fjsonb jsonbset( fjsonb , '{col}' , '"pgxz"' , false ) whereid2; UPDATE 1 teledb