我正在编写一个数据挖掘程序,它批量插入用户数据。
当前的SQL只是一个普通的大容量插入:
insert into USERS(
id, username, profile_picture)
select unnest(array['12345']),
unnest(array['Peter']),
unnest(array['someURL']),
on conflict (id) do nothing;
如果发生冲突,我该如何更新?我试过了:
...
unnest(array['Peter']) as a,
unnest(array['someURL']) as b,
on conflict (id) do
update set
username = a,
profile_picture = b;
但是它抛出了There is a column named "a" in table "*SELECT*", but it cannot be referenced from this part of the query.
错误。
编辑
USERS
表非常简单:
create table USERS (
id text not null primary key,
username text,
profile_picture text
);
https://stackoverflow.com/questions/34514457
复制相似问题