Oracle__11. Oracle 1Z0-051 Exam - Set Operators Flashcards

1
Q

List 4 common set operators?

A
  1. UNION2. UNION ALL3. INTERSECT4. MINUS
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What order are set operators evaluated?

A

Left to Right unless parenthesis are used

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is needed in each select list used in a set?

A

each select must have the same number and data type of columns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

If alias are used in set operators which are used in the final results?

A

The first Select statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the difference between UNION and UNION ALL?

A

UNION eliminates duplicates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

By default what is the sort order in UNION set operator?

A

The first column

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What happens if one select in a column is a CHAR(7) and a CHAR(10) in an Select?

A

The final data type is Varchar2(10) of the largest length.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What happens if one column in a select is Varchar while numeric in the same column in another select?

A

Oracle returns an error.There is not implicit data type conversions in set operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Are null columns ignored in duplicate checking of a UNION?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Is the output of UNION ALL sorted by default?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is returned by the INTERSECT operator?

A

all rows that are common to the both queries.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is returned by the minus operator?

A

All rows from the first table that are not in the second table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Do column names need to be the same in tables for the INTERACT or MINUS set operators?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

If a particular column in the select in a set operation is a VARCHAR and the same column in the other select is a TO_CHAR will it cause an error?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

If a particular column in the select in a set operation is a Number and the same column in the other select is a value of 5 will it cause an error?

A

NoBoth are numbers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Where does the order by clause belong in a set operation?

A

At the very end

17
Q

Using only set operator how can you return promo_category values from table promotions where promo_category is not equal to ‘discount’

A

SELECT promo_categoryFROM promotionsMINUSSELECT promo_categoryFROM promotionsWHERE promo_category = ‘discount’SELECT promo_categoryFROM promotionsINTERSECTSELECT promo_categoryFROM promotionsWHERE promo_category <> ‘discount’

18
Q

Does the INTERSECT remove duplicate rows?

A

Yes

19
Q

What must be the same in both selects of the INTERSECT?

A

The number of column and the order of the data types.The column names to not have to match

20
Q

What 2 different set operator can give you the same result, if you want all promo_category records where the promo_category does not equal discount?

A

SELECT promo_categoryFROM promotionsMINUSSELECT promo_categoryFROM promotionsWHERE promo_category = ‘discount’SELECT promo_categoryFROM promotionsINTERSECTSELECT promo_categoryFROM promotionsWHERE promo_category <> ‘discount’

21
Q

Will this statement produce an error? MERGE INTO bonuses D USING (SELECT employee_id, salary, department_id FROM employees WHERE department_id = 80) S ON (D.employee_id = S.employee_id) WHEN MATCHED THEN UPDATE SET D.bonus = D.bonus + S.salary.01 DELETE WHERE (S.salary > 8000) WHEN NOT MATCHED THEN INSERT (D.employee_id, D.bonus) VALUES (S.employee_id, S.salary0.1) WHERE (S.salary <= 8000);

A

No error, this statement is validThe WHEN MATCHED and WHEN NOT MATCHED occur after the JOIN and WHERE clauses

22
Q

Between WHEN MATCHED and THEN NOT MATCHED, where does the SET clause belong in a MERGE statement?

A

in the WHEN MATCHEDThere must matching records to be updated by the SET

23
Q

Between WHEN MATCHED and THEN NOT MATCHED, where does the DELETE clause belong in a MERGE statement?

A

in the WHEN MATCHEDThere must matching records to be deleted

24
Q

Between WHEN MATCHED and THEN NOT MATCHED, where does the INSERT clause belong in a MERGE statement?

A

in the WHEN NOT MATCHNo record can exist if any records are inserted

25
Q

What is the return from this series of statements? SELECT 1 FROM dual UNION SELECT 2 FROM dual UNION SELECT 3 FROM dual UNION ALL SELECT 3 FROM dual MINUS SELECT 2 FROM dual INTERSECT SELECT 1 FROM dual

A

1The sequence is from top to bottom.The after the 3 unions there are 3 recordsThe union all add 1 more record (a union would not have added it)The minus remove 1 record.The intersect only matches the records with the value of 1

26
Q

What is returned with this statement? SELECT na FROM promo ORDER BY 1 DESC UNION SELECT na FROM promo WHERE cat = ‘TV’

A

an error because the ORDER BY clause must the last statement for any set operators such as UNION

27
Q

What is returned with this statement? SELECT na name1 FROM promo UNION SELECT na name2 FROM promo WHERE cat = ‘TV’ ORDER BY 1 DESC

A

The field name will be name1 and it will be sorted in descending order

28
Q

Does reversing tables using an INTERSECT operation change the results?

A

No.On reversing the order of the intersected table, it does not alter the result

29
Q

In a UNION are null values ignored?

A

No