语句介绍:
DO NOTHING:当记录存在时,什么都不做
DO UPDATE SET column_1 = value_1, … WHERE condition:当记录存在时,更新表中的一些字段
实例语句:
name默认为主键
存在则更新,不存在则插入
INSERT INTO customers (name, email)
VALUES('Microsoft','hotline@microsoft.com')
ON CONFLICT (name)
DOUPDATESET email = EXCLUDED.email;
存在则忽略,不存在则插入
INSERT INTO customers (name, email)
VALUES('Microsoft','hotline@microsoft.com')
ON CONFLICT (name)
DO NOTHING;