thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Data & Analytics · Intermediate

MERGE Statement

A single DML statement that inserts, updates or deletes target rows based on whether they match rows in a source.

Definition

MERGE (MERGE INTO in Databricks and Snowflake) compares a source with a target on a join condition and applies WHEN MATCHED and WHEN NOT MATCHED actions. It is the standard way to apply incremental loads, CDC feeds and SCD logic.

Example

MERGE INTO dim_customer t USING stg s ON t.id = s.id WHEN MATCHED THEN UPDATE SET t.email = s.email WHEN NOT MATCHED THEN INSERT (id, email) VALUES (s.id, s.email);

Exam tip

MERGE fails or behaves unpredictably if several source rows match one target row; deduplicate the source first.

Related terms