我想在postgresql中插入以下值,我需要使用哪种数据类型以及如何构造插入查询?

时间:2017-04-25 12:54:56

标签: postgresql

数据是json数组

[{ "customer": "John Doe", "items": {"product": "Beer","qty": 6}}, { "staff" : "Jack" }]

1 个答案:

答案 0 :(得分:0)

将其存储为json(或jsonb

create table sameesh
(
   data json
);

insert into sameesh (data)
values 
('[{ "customer": "John Doe", "items": {"product": "Beer","qty": 6}}, { "staff" : "Jack" }]');