SQL Union MCQs
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?
A. COMBINE
B. CONCAT
C. JOIN
D. UNION
View Answer
Ans : D
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;
A. row name
B. column name
C. table name
D. database name
View Answer
Ans : B
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?
A. ALL
B. NARROW
C. STRICT
D. DISTINCT
View Answer
Ans : D
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?
A. LIMIT
B. ORDER BY
C. GROUP BY
D. SORT
View Answer
Ans : B
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 _____________
A. UNION ALL
B. UNION
C. UNION DISTINCT
D. JOIN
View Answer
Ans : A
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?
A. SELECT column_name(s) FROM table_name1 UNION table_name2
B. SELECT column_name(s) FROM table_name1 UNION SELECT column_name(s) FROM table_name2
C. UNION SELECT column_name(s) FROM table_name1 SELECT column_name(s) FROM table_name2
D. SELECT FROM table_name1 AND table_name2
View Answer
Ans : B
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?
A. UNION
B. UNION ALL
C. None of the above
D. Both A and B
View Answer
Ans : A
Explanation: UNION command displays distinct rows.
8. Is UNION or UNION ALL operator valid for LONG data type column?
A. True True
B. True False
C. False True
D. False False
View Answer
Ans : D
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?
A. UNION
B. UNION ALL
C. Both A and B
D. None of the above
View Answer
Ans : B
Explanation: UNION ALL is used
10. Which of the following statement(s) is/are True about UNION?
A. Data Types in all queries in a UNION must match position wise
B. Column Names in all queries in a UNION must match position wise
C. UNION can be used with UPDATE statement
D. None of the above
View Answer
Ans : A
Explanation: Data Types in all queries in a UNION must match position wise statement(s) is/are True about UNION
Also check :
Discussion