SQL错误“列“ zona”的类型为box,但表达式的类型为record”

时间:2019-11-27 22:55:36

标签: sql postgresql record

我是SQL的新手,我看到了与此类似的问题,但是仅通过查看这些解决方案就无法解决问题。 (在postgres上工作)

我有一个桌子异常:

create table anomalia(
  id integer,
  zona box not null,
  imagem varchar(50) not null,
  lingua char(3) not null,
  ts timestamp not null,
  descricao text not null,
  tem_anomalia_redacao boolean not null,
  primary key(id)
);

,当我尝试:

insert into anomalia values (22, ((2, 4), (8, 9)), 'imagem2.png', 'por', '2003-09-21 22:54:56', 'Texto muito pequeno', TRUE);

我收到此错误:

psql:schema.sql:129: ERROR:  column "zona" is of type box but expression is of type record                           
LINE 1: insert into anomalia values (22, ((2, 4), (8, 9)), 'imagem2....

从我读到的内容来看,问题很可能与括号有关,但我无法弄清楚。如果您想帮助您,将非常感谢!

1 个答案:

答案 0 :(得分:1)

用单引号简单地包围zona字段的值,如下所示:

insert into anomalia values (22, '((2, 4), (8, 9))', 'imagem2.png', 'por', '2003-09-21 22:54:56', 'Texto muito pequeno', TRUE);