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 keyword used with UNION retains duplicate rows?
A. ALL
B. NARROW
C. STRICT
D. DISTINCT
View Answer
Ans : A
Explanation: The keyword ALL used along with UNION is not synonymous with just the UNION statement. It produces the duplicate rows, if they exist, from the combination of the two tables in the SELECT query.
5. 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.
6. Which table is used to run a UNION-type query on MyISAM tables?
A. TRADITIONAL
B. MERGE
C. SERVELET
D. UNITE
View Answer
Ans : B
Explanation: When there is a need to run a UNION type operation on a MyISAM table that has the same structures, a MERGE table is set up for it. After this, the queries are performed on this table.
7. 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.
8. What does UNION operator do in a SQL Server statement?
A. Bring common data from the listed tables.
B. Bring data which is not common from the listed tables.
C. Bring all data from the listed tables.
D. Bring all distinct from the listed tables.
View Answer
Ans : D
Explanation: UNION operator bring all distinct from the listed tables.
9. 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.
10. What is true about order by with Union operator?
A. Order By can be issued in each result set.
B. It can be issued for the overall result set.
C. Both A & B.
D. None of the above
View Answer
Ans : B
Explanation: It can be issued for the overall result set is true about order by with Union operator.
11. 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.
12. Which of the following statement is TRUE about UNION?
A. Each query in a UNION can be sorted independently in different sort orders
B. All the queries in a UNION must be against the same table
C. UNION clause is used to subtract rows of second query from the first query
D. UNION and UNION ALL give same result if the participating queries are mutually exclusive
View Answer
Ans : D
Explanation: UNION and UNION ALL give same result if the participating queries are mutually exclusive statement is TRUE about UNION.
13. 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.
14. 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
15. 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
16. Which of the following is not Constraint in SQL?
A. Primary Key
B. Not Null
C. Check
D. Union
View Answer
Ans : D
Explanation: Union is following is not Constraint in SQL.
17. Which of the following is one of the basic approaches for joining tables?
A. Subqueries
B. Union Join
C. Natural join
D. All of the above
View Answer
Ans : D
Explanation: All of the following is one of the basic approaches for joining tables.
Also check :
Discussion