无则插入有则更新
PostgreSQL
无则插入有则更新
conflict(带有唯一性约束的字段),根据此字段判断是更新还是插入
sql
INSERT INTO student(id,name,sex)
VALUES
('1', '小明', '男') ON conflict (id) DO
UPDATE
SET id= '1',
name= '小明',
sex= '男';
无则插入有则不做操作
sql
INSERT INTO student(id,name,sex)
VALUES
('1', '小明', '男') ON conflict (id) DO nothing;
MySQL,Oracle、SqlServer
mysql :https://www.cnblogs.com/luoxiao1104/p/17027999.html
[MySQL,Oracle,SqlServer ]:https://blog.csdn.net/weidu01/article/details/111939654