
Answer-first summary for fast verification
Answer: When the target table cannot contain duplicate records
The MERGE INTO command is used when you need to perform both insertions and updates (or deletes) in one operation based on whether a match exists. It is particularly useful for maintaining up-to-date data and ensuring there are no duplicate records in the target table. This is often referred to as an 'upsert' operation (update + insert). When the target table needs to be kept free of duplicate records, and there's a need to update existing records or insert new ones based on some matching condition, MERGE INTO is the appropriate command. The INSERT INTO command, on the other hand, is used to add new records to a table without regard for whether they duplicate existing records. Options A, B, C, and E do not specifically require the use of MERGE INTO. Therefore, D is the correct answer.
Author: LeetQuiz Editorial Team
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
D
When the target table cannot contain duplicate records
E
When the source is not a Delta table
No comments yet.