鉴于:
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)
);
Run Code Online (Sandbox Code Playgroud)
这个查询:
insert into table_b (pk_b, b)
select pk_a,a from table_a
on conflict (b) do update set b=a;
Run Code Online (Sandbox Code Playgroud)
导致以下错误:
Run Code Online (Sandbox Code Playgroud)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 …