The MERGE statement in SQL, also known as UPSERT, allows conditional INSERT, UPDATE, or DELETE operations in a single command. It is commonly used for synchronizing tables. This quiz explores its syntax, use cases, and behavior.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
What is the purpose of the MERGE statement in SQL?
Correct
Incorrect
Question 2 of 15
2. Question
What does UPSERT mean in SQL terminology?
Correct
Incorrect
Question 3 of 15
3. Question
Which of the following SQL keywords are typically used with MERGE?
Correct
Incorrect
Question 4 of 15
4. Question
What does the ON clause specify in a MERGE statement?
Correct
Incorrect
Question 5 of 15
5. Question
What action is performed in WHEN MATCHED THEN UPDATE?
Correct
Incorrect
Question 6 of 15
6. Question
In MERGE, what happens in WHEN NOT MATCHED THEN INSERT?
Correct
Incorrect
Question 7 of 15
7. Question
Which two clauses are essential in a complete MERGE statement?
Correct
Incorrect
Question 8 of 15
8. Question
Which scenario best describes the use of MERGE?
Correct
Incorrect
Question 9 of 15
9. Question
Which database systems support the MERGE statement?
Correct
Incorrect
Question 10 of 15
10. Question
What can go wrong if the ON clause produces multiple matches for the same target row?
Correct
Incorrect
Question 11 of 15
11. Question
Which of the following statements is TRUE about MERGE?
Correct
Incorrect
Question 12 of 15
12. Question
Can MERGE be used to delete records?
Correct
Incorrect
Question 13 of 15
13. Question
What is the role of an alias in a MERGE statement?
Correct
Incorrect
Question 14 of 15
14. Question
What will this snippet do?
MERGE INTO products p
USING new_products np
ON (p.id = np.id)
WHEN MATCHED THEN UPDATE SET p.name = np.name
WHEN NOT MATCHED THEN INSERT (id, name) VALUES (np.id, np.name);
Correct
Incorrect
Question 15 of 15
15. Question
Which clause is used in PostgreSQL 15+ for upsert behavior if `MERGE` is unavailable?
Correct
Incorrect
Summary
Understanding MERGE (UPSERT) is crucial for efficiently handling data synchronization and deduplication in SQL. These MCQs will test your grasp of matching logic, source/target behavior, and real-world MERGE scenarios.
At QuizOrbit, our team specializes in fun, informative quizzes across topics like general knowledge, technology, and entertainment. Boost your knowledge with our expert-designed quizzes.