PostgreSQL Database Quiz Questions

Course Name:PostgreSQL
Chapter Name:Chapter 7 - DQL (Data Query Language)
Lesson Content Link:UNION and UNION ALL
Current Quiz Count:30
Progress
0%
Q1
True / False

In PostgreSQL, the UNION operator returns only distinct rows from the combined result set of two or more queries.

Q2
True / False

The UNION ALL operator in PostgreSQL also removes duplicate rows from the combined result set.

Q3
True / False

In PostgreSQL, both the UNION and UNION ALL operators require the same number of columns in their result sets.

Q4
True / False

: Using UNION in PostgreSQL is faster than using UNION ALL because it removes duplicates.

Q5
True / False

In PostgreSQL, the column names of the result set of a UNION query are taken from the first SELECT statement.

Q6
True / False

When using UNION in PostgreSQL, the data types of the corresponding columns in the SELECT statements must be compatible.

Q7
True / False

In PostgreSQL, you can use the ORDER BY clause with the individual SELECT statements within a UNION query.

Q8
True / False

PostgreSQL allows the use of LIMIT and OFFSET clauses in individual SELECT statements within a UNION ALL operation.

Q9
True / False

The UNION operator in PostgreSQL guarantees the order of the result set based on the order of the input queries.

Q10
True / False

In PostgreSQL, a UNION ALL operation can be used to combine result sets from different schemas within the same database.

Q11
Single Choice

What is the main difference between the UNION and UNION ALL operators in PostgreSQL?

Q12
Single Choice

Which of the following queries will return all rows, including duplicates, from the employees and managers tables in PostgreSQL?

Q13
Single Choice

Which PostgreSQL keyword is used to combine the result sets of two or more SELECT statements and remove duplicates?

Q14
Single Choice

Given the following SQL code, what will be the output?

SQL Code
SELECT name FROM employees
UNION ALL
SELECT name FROM managers;
Q15
Single Choice

How can you modify the following PostgreSQL query to remove duplicate rows from the result set?

SQL Code
SELECT department FROM employees
UNION ALL
SELECT department FROM managers;
Q16
Single Choice

Which of the following SQL statements correctly uses UNION to combine results from two different tables in PostgreSQL?

Q17
Single Choice

Given two PostgreSQL queries that use UNION and UNION ALL, which one will have a better performance when dealing with large datasets?

Q18
Single Choice

In PostgreSQL, which of the following SQL queries will correctly return all distinct city names from the customers and suppliers tables, ensuring there are no duplicates?

Q19
Single Choice

When using UNION ALL in PostgreSQL, what happens if the number of columns in the SELECT statements does not match?

Q20
Single Choice

Consider the following SQL query in PostgreSQL:

SQL Code
SELECT id, name FROM students
UNION
SELECT id, name FROM alumni
UNION ALL
SELECT id, name FROM faculty;
What will be the total number of rows returned if the students and alumni tables each have 10 rows (with 2 common rows), and the faculty table has 5 rows with no duplicates in other tables?
Q21
Multiple Choice

Which SQL queries correctly use UNION to combine results from two tables in PostgreSQL?

Q22
Multiple Choice

Identify the SQL queries that correctly use UNION ALL to combine results from multiple SELECT statements in PostgreSQL.

Q23
Multiple Choice

Which SQL queries correctly apply UNION and UNION ALL to combine and filter data from multiple tables in PostgreSQL?

Q24
Multiple Choice

Determine the SQL queries that correctly use UNION and UNION ALL with different SELECT statements in PostgreSQL.

Q25
Multiple Choice

Identify the SQL queries that correctly use UNION and UNION ALL to merge data from 'projects' and 'completed_projects' tables in PostgreSQL.

Q26
Multiple Choice

Which SQL queries correctly use UNION and UNION ALL with filters in PostgreSQL?

Q27
Multiple Choice

Identify the SQL queries that correctly use UNION and UNION ALL to merge results from multiple SELECT statements in PostgreSQL.

Q28
Multiple Choice

Determine the SQL queries that correctly use UNION to remove duplicates from combined results in PostgreSQL.

Q29
Multiple Choice

Which SQL queries correctly apply UNION ALL to include all rows from combined SELECT statements in PostgreSQL?

Q30
Multiple Choice

Identify the SQL queries that correctly use UNION to merge results and filter data from multiple tables in PostgreSQL.