我有以下结构的表“详细信息”

id     status1      status2    names
 1    approved     rejected     NULL
 2    approved     rejected     NULL
 3    approved     rejected     NULL
 4    rejected     rejected     NULL

我想使用默认值{john,smith}将值插入数组“名称”数组

例子:我需要
  id     status1      status2    names
   1    approved     rejected   {john,smith}
   2    approved     rejected   {john,smith}
   3    approved     rejected   {john,smith}
   4    rejected     rejected   {john,smith}

我写的时候失败了
INSERT INTO details (names) VALUES(ARRAY['john', 'smith']);

最佳答案

INSERT创建全新的行-但您想更改现有行,因此需要使用 UPDATE :

update details
  set names  = ARRAY['john', 'smith'];

10-08 14:28