鉴于:
CREATE TABLE A (
PK_A INT8 NOT NULL,
A INT8,
PRIMARY KEY (PK_A)
);
CREATE TABLE B (
PK_B INT8 NOT NULL,
B INT8,
PRIMARY KEY (PK_B)
);
该查询:
insert into table_b (pk_b, b)
select pk_a,a from table_a
on conflict (b) do update set b=a;
导致以下错误:
ERROR: column "a" does not exist LINE 1: ...elect pk_a,a from table_a on conflict (b) do update set b=a; ^ HINT: There is a column named "a" in table "*SELECT*", but it cannot be referenced from this part of the query.
参照的内容时如何进行更新table_a
?
在
—
Patrick7
do update set b = a;
无法找到“A”,因为表“B”,而不是子查询参考,尝试do update set b = (select a from a);
CREATE TABLE A...
创建表a
,不是table_a
。