原来一个特殊的表名为excluded
包含要插入的行(虽然名字很奇怪)
insert into USERS( id, username, profile_picture) select unnest(array['12345']), unnest(array['Peter']), unnest(array['someURL']) on conflict (id) do update set username = excluded.username, profile_picture = excluded.profile_picture;
http://www.postgresql.org/docs/9.5/static/sql-insert.html#SQL-ON-CONFLICT
ON CONFLICT DO UPDATE中的SET和WHERE子句可以使用表的名称(或别名)访问现有行,并使用特殊排除表访问建议插入的行...