如何实现UPSERT(合并,插入…)关于重复更新)在PostgreSQL中?
INSERT ... ON DUPLICATE UPDATE
MERGE
CREATE TABLE testtable ( id integer PRIMARY KEY, somedata text NOT NULL);INSERT INTO testtable (id, somedata) VALUES(1, 'fred'),(2, 'bob');
(2, 'Joe')
, (3, 'Alan')
(1, 'fred'),(2, 'Joe'), -- Changed value of existing tuple(3, 'Alan') -- Added new tuple
upsert
相关分类