11 Set operators

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/25

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

26 Terms

1
New cards

What are the four set operators in Oracle SQL?

UNION, UNION ALL, INTERSECT, MINUS

2
New cards

What does the UNION operator do?

It merges row sets from two SELECT statements and eliminates duplicate rows.

3
New cards

What does the UNION ALL operator do?

It merges row sets from two SELECT statements but does not eliminate duplicates.

4
New cards

What does the INTERSECT operator do?

It returns only those rows that are present in both SELECT statements, eliminating duplicates.

5
New cards

What does the MINUS operator do?

It returns rows from the first SELECT that are not present in the second SELECT.

6
New cards

What requirements must SELECT statements meet to use set operators?

Same number of expressions in select list, matching data type groups (automatic data type conversion included) for each expression, no BLOB/CLOB, LOB types, ORDER BY only at the end. They don’t have to have matching column names or table names.

7
New cards

Can set operators be used without primary/foreign key relationships between tables?

Yes, the SELECT statements do not need relational keys.

8
New cards

Where can the ORDER BY clause be used when combining SELECT statements with set operators?

Only once, after the last SELECT statement.

9
New cards

What happens if the first SELECT statement has a different column heading?

The final output takes column names/aliases from the first SELECT.

10
New cards

How do set operators handle precedence?

All set operators have equal precedence and execute left to right unless parentheses change it.

11
New cards

How can you change the execution order of set operators?

Use parentheses to override default precedence.

12
New cards

What happens if you use ORDER BY inside an inner SELECT when combining with set operators?

It is not allowed; ORDER BY can only appear at the end of the full query.

13
New cards

What happens if duplicates exist in INTERSECT results?

Duplicates are eliminated.

14
New cards

What is different about MINUS compared to UNION, UNION ALL, and INTERSECT?

The order of SELECT statements matters for MINUS.

15
New cards

How can rows be sorted when using set operators?

By position or by reference, but only at the end of the query.

16
New cards

What does ORDER BY by position mean?

Refers to sorting using the column’s ordinal number in the select list.

17
New cards

What does ORDER BY by reference mean?

Refers to sorting using column names or aliases from the first SELECT statement.

18
New cards

Which SELECT statement's column names are valid for ORDER BY when using set operators?

Only column names or aliases from the first SELECT statement.

19
New cards

What is the correct placement of ORDER BY in queries with set operators?

It must be the final clause in the SQL statement.

20
New cards

Which keyword is NOT a set operator?

SET

21
New cards

Which set operator should you use to find rows in one table that are not in another?

MINUS

22
New cards

Which set operator’s result depends on the order of SELECT statements?

MINUS

23
New cards

Can set operators be used with INSERT statements?

No, they only work with SELECT statements.

24
New cards

How many ORDER BY clauses are allowed when combining SELECT statements with set operators?

Only one, and it must be at the end.

25
New cards

What do SET operators do?

They combine two or more SELECT statements similar to joins but in a different way

26
New cards

Is there a limit how many SET operators there can be?

No