postgresql update1 postgresql merge(upsert) 구현하기 postgresql merge(upsert+delete) 구현하는 방법이다. 이걸 1트랜잭션으로 묶거나 프로시저나 펑션 등으로 호출하면 된다. lock table test_tbl in exclusive mode; delete from test_tbl where not exists ( select 1 from tmp_test_tbl where test_tbl.pk = tmp_test_tbl.pk ) ; update test_tbl set pk = tmp_test_tbl.pk , c1 = tmp_test_tbl.c1 , c2 = tmp_test_tbl.c2 , c3 = tmp_test_tbl.c3 from tmp_test_tbl where test_tbl.pk = tmp_test_tbl.pk ; insert.. 2019. 7. 27. 이전 1 다음