
Ultimate access to all questions.
In which of the following scenarios should a data engineer use the MERGE INTO command instead of the INSERT INTO command?
A
When the location of the data needs to be changed
B
When the target table is an external table
C
When the source table can be deleted
Explanation:
The correct answer is C. When the source table can be deleted.
MERGE INTO (also known as UPSERT) is used when you need to:
INSERT INTO is used when you simply want to append new data to a table without checking for existing records.
A. When the location of the data needs to be changed - This is incorrect. Changing data location is typically handled by ALTER TABLE commands or by creating new tables, not by MERGE INTO.
B. When the target table is an external table - This is incorrect. Both MERGE INTO and INSERT INTO can work with external tables in Databricks. The table type doesn't determine which command to use.
C. When the source table can be deleted - This is CORRECT. MERGE INTO is particularly useful when you need to handle scenarios where:
If you have a customer table and receive daily updates, you would use MERGE INTO to:
This is why option C is correct - when source data might be deleted or removed, MERGE INTO with DELETE clause is the appropriate command to handle such scenarios.