Recall & Review
beginner
What does the SQL UNION ALL operator do?
UNION ALL combines the results of two or more SELECT queries and includes all rows, even duplicates.
Click to reveal answer
beginner
How does UNION ALL differ from UNION?
UNION removes duplicate rows from the combined result, while UNION ALL keeps all duplicates.
Click to reveal answer
beginner
Given two tables with overlapping data, which operator would you use to keep all rows including duplicates?
Use UNION ALL to keep all rows including duplicates from both tables.
Click to reveal answer
beginner
Write a simple SQL query using UNION ALL to combine two tables named 'A' and 'B' with the same columns.
SELECT * FROM A UNION ALL SELECT * FROM B;
Click to reveal answer
intermediate
Why might you choose UNION ALL over UNION in a query?
Because UNION ALL is faster since it does not check for duplicates, and you want to keep all rows including duplicates.
Click to reveal answer
What happens to duplicate rows when using UNION ALL?
✗ Incorrect
UNION ALL keeps all rows including duplicates.
Which SQL operator removes duplicate rows when combining results?
✗ Incorrect
UNION removes duplicates, UNION ALL does not.
Which operator is generally faster when combining two result sets?
✗ Incorrect
UNION ALL is faster because it does not check for duplicates.
If you want to combine two tables and keep all rows including duplicates, which query is correct?
✗ Incorrect
UNION ALL keeps all rows including duplicates.
What is a key reason to use UNION ALL instead of UNION?
✗ Incorrect
UNION ALL is faster because it skips duplicate removal.
Explain the difference between UNION and UNION ALL in SQL.
Think about how duplicates are handled and speed.
You got /3 concepts.
Describe a scenario where using UNION ALL is better than UNION.
Consider when duplicates are important and speed matters.
You got /3 concepts.