SQL 错误 'column "zona" is of type box but expression is of type record'
SQL error 'column "zona" is of type box but expression is of type record'
我是 SQL 的新手,我看到过与此类似的问题,但是我无法仅通过查看这些解决方案来解决我的问题。
(在 postgres 上工作)
我有一个 table 异常:
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....
根据我的阅读,问题很可能与括号有关,但我无法弄清楚。如果您能提供帮助,将不胜感激!
只需用单引号将 zona 字段的值括起来,如下所示:
insert into anomalia values (22, '((2, 4), (8, 9))', 'imagem2.png', 'por', '2003-09-21 22:54:56', 'Texto muito pequeno', TRUE);
我是 SQL 的新手,我看到过与此类似的问题,但是我无法仅通过查看这些解决方案来解决我的问题。 (在 postgres 上工作)
我有一个 table 异常:
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....
根据我的阅读,问题很可能与括号有关,但我无法弄清楚。如果您能提供帮助,将不胜感激!
只需用单引号将 zona 字段的值括起来,如下所示:
insert into anomalia values (22, '((2, 4), (8, 9))', 'imagem2.png', 'por', '2003-09-21 22:54:56', 'Texto muito pequeno', TRUE);