Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

1Z0-007 exam question

Tags:

sql

plsql

Question: In which four clauses can a subquery be used? (Choose four.)

A. in the INTO clause of an INSERT statement

B. in the FROM clause of a SELECT statement

C. in the GROUP BY clause of a SELECT statement

D. in the WHERE clause of a SELECT statement

E. in the SET clause of an UPDATE statement

F. in the VALUES clause of an INSERT statement

Answer: B, D, E, F

But I think right answers are the following: A, B, D, E BUT NOT F. Is not it so???

like image 214
kupa Avatar asked Dec 06 '25 20:12

kupa


2 Answers

No, B, D, E, F sounds correct.

Why do you thik A should be valid? The INTO is designating a target rowset, which cannot be a subquery. And in F you can use subqueries which return a scalar value just fine.

like image 199
Lucero Avatar answered Dec 08 '25 14:12

Lucero


First of all we must acknowledge that a subquery returns a set of value tuples (rows): {(value_1_A, value_1_B, ...), (value_2_A, value_2_B, ...), ...}

A - The INTO clause expects a table name, not a set of values so you may not use a subquery. Note that this is not similar to B because you are allowed to query an anonymous table (a set of rows returned by a subquery), but it makes no sense to insert values into an anonymous table that will not be used.

F - The VALUES clause of the INSERT statement expects exactly what I said a subquery returns, a set of values.

The right answer will be B, D, E and F.

Here's some more info on subqueries: http://www.techonthenet.com/oracle/subqueries.php

like image 36
Alin Purcaru Avatar answered Dec 08 '25 16:12

Alin Purcaru



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!