postgres sql merge upsert
https://www.jb51.net/article/156093.htm
-
插入,关于冲突-无所事事.
insert into dummy(id, name, size) values(1, 'new_name', 3) on conflict do nothing;
-
插入,关于冲突-做更新,指定冲突目标列.
insert into dummy(id, name, size) values(1, 'new_name', 3) on conflict(id) do update set name = 'new_name', size = 3;
-
插入,关于冲突-做更新,指定冲突目标约束名称.
insert into dummy(id, name, size) values(1, 'new_name', 3) on conflict on constraint dummy_pkey do update set name = 'new_name', size = 4;