更新数据
最近更新时间: 2025-02-18 16:02:00
- 增加元素。
postgres=# update t_jsonb set f_jsonb = f_jsonb || '{"col3":"pgxz"}'::jsonb where id=1;
UPDATE 1
- 更新原来的元素。
postgres=# update t_jsonb set f_jsonb = f_jsonb || '{"col2":"TDSQL PG"}'::jsonb where id=3;
UPDATE 1
postgres=# select * from t_jsonb;
id | f_jsonb
----+----------------------------------------------
2 | {"col1": 1, "col2": "TDSQL PG", "col3": "pgxz"}
1 | {"col1": 1, "col2": "TDSQL PG", "col3": "pgxz"}
3 | {"col1": 1, "col2": "TDSQL PG"}
(3 rows)
- 删除某个键。
postgres=# update t_jsonb set f_jsonb = f_jsonb - 'col3';
UPDATE 3
postgres=# select * from t_jsonb;
id | f_jsonb
----+------------------------------
2 | {"col1": 1, "col2": "TDSQL PG"}
1 | {"col1": 1, "col2": "TDSQL PG"}
3 | {"col1": 1, "col2": "TDSQL PG"}
(3 rows)