实际上,我的问题基本上是same as here,但是我需要将嵌套查询中的值插入到现有表中,而我对sql不那么了解,因为它不知道如何将setval
部分并入我的查询中:] >
insert into table_a select * from table_b where val_1 IN (select "val_1" from table_c where "val_2" is null)
返回
ERROR: duplicate key value violates unique constraint "table_a_pkey" DETAIL: Key (qid)=(470971) already exists.
现在,我知道我可以按照here的说明使用drop column和autgenerate进行变通,但是必须有一种更优雅的方法。我正在使用Postgresql / Postgis 2.4 btw。
实际上,我的问题与此处基本相同,但我需要将嵌套查询中的值插入现有表中,而我对sql不太了解,以了解如何合并setval ...