MERGE
The Anatomy of a MERGE Statement
MERGE StatementMERGE INTO target_table AS t
USING source_table AS s
ON t.id = s.id
WHEN MATCHED THEN
UPDATE SET name = s.name, updated_at = NOW()
WHEN NOT MATCHED THEN
INSERT (id, name, created_at) VALUES (s.id, s.name, NOW());The Three Main Clauses
MERGE vs. INSERT ... ON CONFLICT
MERGE vs. INSERT ... ON CONFLICTImplementation in Data Pipelines (The "SCD Type 1" Pattern)
Visualizing the MERGE Flow
Summary
Last updated