1 Resposta
- Mais recentes
- Mais votos
- Mais comentários
0
【以下的回答经过翻译处理】 由于客户正在更新JSON文档中的值,因此只需使用内置的PostgreSQL JSON函数。
postgres=> CREATE TABLE test_json (a int, b jsonb);
CREATE TABLE
postgres=> INSERT INTO test_json
postgres-> VALUES (1, '{"key1": "abc"}'), (2, '{"key1": "xyz"}');
INSERT 0 2
postgres=> UPDATE test_json
postgres-> SET b = jsonb_set(b, '{key1}', (upper((b->'key1')::text))::jsonb);
UPDATE 2
postgres=> SELECT * FROM test_json;
a | b
---+-----------------
1 | {"key1": "ABC"}
2 | {"key1": "XYZ"}
(2 rows)
Conteúdo relevante
- AWS OFICIALAtualizada há 2 anos