插入数据
最近更新时间: 2025-02-18 16:02:00
postgres=# insert into t_jsonb values(1,'{"col1":1,"col2":"TDSQL PG"}');
INSERT 0 1
postgres=# insert into t_jsonb values(2,'{"col1":1,"col2":"TDSQL PG","col3":"pgxz"}');
INSERT 0 1
postgres=# select * from t_jsonb;
id | f_jsonb
----+----------------------------------------------
1 | {"col1": 1, "col2": "TDSQL PG"}
2 | {"col1": 1, "col2": "TDSQL PG", "col3": "pgxz"}
(2 rows)
jsonb插入时会移除重复的键,如下所示:
postgres=# insert into t_jsonb values(3,'{"col1":1,"col2":"TDSQL PG","col2":"pgxz"}');
INSERT 0 1
postgres=# select * from t_jsonb;
id | f_jsonb
----+----------------------------------------------
1 | {"col1": 1, "col2": "TDSQL PG"}
3 | {"col1": 1, "col2": "pgxz"}
2 | {"col1": 1, "col2": "TDSQL PG", "col3": "pgxz"}
(3 rows)