如何在sql的新列中插入多列的内容?

时间:2014-12-02 10:50:29

标签: sql postgresql

我想合并两列的内容并将其插入新列。

但它不起作用。 例如:

create table car(
   id bigint NOT NULL,
   manufacture character varying(255),
   number character varying(255),
   result character varying(255)
)

insert into car (result)
select concat(manufacture, ' ', number) from car

结果:

ERROR:  NULL-Value in column „id“ error Not-Null-Constraint
DETAIL:  Failed line contains (null, null, null, bmw 123).

如何更新特定行,并保留所有其他值不变?

1 个答案:

答案 0 :(得分:3)

update car set result = concat(manufacture, ' ', number)