SQL Union MCQs
This section focuses on the "Union" of the SQL. These Multiple Choice Questions (mcq) should be practiced to improve the SQL skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1. To combine multiple retrievals, we write several SELECT statements and put the keyword between them. What is the keyword?
Explanation: The UNION operator is used for combining the results of various SELECT queries into one. For example, SELECT a FROM table1 UNION SELECT a FROM table2; produces the results from tables table1 concatenated with that of table2.
2. What is xyz in the following SQL statement? SELECT xyz FROM table1 UNION xyz FROM table2;
Explanation: The SELECT queries can be combined together using the UNION operator to produce the concatenated results from two or more tables. The data type of the columns is not taken into account.
3. Which keyword used with UNION does not retain duplicate rows?
Explanation: The keyword DISTINCT used along with UNION is synonymous with just the UNION statement. It produces only the distinct rows from the combination of the two tables in the SELECT query.
4. Which clause is used to sort a UNION result as a whole?
Explanation: The ORDER BY clause is used along with the UNION statement to sort a UNION result as a whole. It is placed after the last SELECT statement which is kept in parenthesis.
5. SELECT on a MERGE table is like _____________
Explanation: Performing a SELECT operation on a MERGE table is like performing UNION ALL. This means that duplicate row results are not removed. SELECT DISTINCT is like UNION or UNION DISTINCT.
6. Which one is correct syntax for applying UNION operator?
Explanation: SELECT column_name(s) FROM table_name1 UNION SELECT column_name(s) FROM table_name2 correct syntax for applying UNION operator.
7. Which of the following command displays distinct rows?
Explanation: UNION command displays distinct rows.
8. Is UNION or UNION ALL operator valid for LONG data type column?
Explanation: UNION or UNION ALL operator are not valid for LONG data type column.
9. If we know the records returned by our query are unique then which operator will be preferred out of UNION or UNION ALL?
Explanation: UNION ALL is used
10. Which of the following statement(s) is/are True about UNION?
Explanation: Data Types in all queries in a UNION must match position wise statement(s) is/are True about UNION
Also check :