Examine this SQL statement:
Which two are true? (Choose two.)
Examine this SQL statement:
Which two are true? (Choose two.)
In the provided SQL statement, all existing rows in the ORDERS table are updated, even if no match is found in the subquery, causing the customer_name to be set to NULL for those rows. The subquery is a correlated subquery, meaning it is executed for every row in the ORDERS table to get the appropriate customer name from the CUSTOMERS table. The subquery is not executed before the UPDATE statement as the subquery must run for each row being updated to retrieve the correct value. Furthermore, if the subquery selects multiple rows, the update statement would fail with an error.
A and D tested on Oracle 12c1
BD, A is incorrect only matching rows are updated, not all C is invalid, statement correct structure E is incorrect, in case multiple rows, error multiple rows in subquery
definitely agree. Oracle will only update the rows that are matched
No, it will update unmatched rows with NULL
Incorrect
Actually i though in that way. But most likely customer table is PK. Orders table is FK. So it means the data that in the orders table also have in the customers table. And all rows will be updated.
Answer: A and D are correct. B is not correct because the subquery is executed for each row in the ORDERS table, not before the update statement is executed. C is not correct because the subquery is a correlated subquery, not a non-correlated subquery. E is not correct because if the subquery selects multiple rows, the update statement will fail with a "subquery returns more than one row" error.
I think B is correct, as you said subquery will execute for each row its right but also update will update for each raw after fulfilling the condition of subquery :) Then how update will update each raw ? update will check its resources "subquery" is condition met ? yes ? then update after execute subquery and fully checking it.
how is B not correct, isn't it obviously gonna run the subquery before it updates the row?
B (false), depending EXPLAIN PLAN. no always is executed first. C (false), ".o" is correlative E (false) is possible multiple rows, an error more than row. A and D is correct
AD are correct
E - wrong because will cause an error "ORA-01427: Subquery returns more than one row"
A and E are correct answers
what is an answer in exam? i thin AD are correct.
I mean B not D
SHOULD BE b AND d
sHOULD BE a AND d
AD option is right
AD; cannot be B, correlated subqueries are not executed before the parent (outer) query. Cannot be E, cannot set customer_name to multiple values for each row
A is correct D :It will retrieve the matching value for each row from the table orders with the table customers
Can someone explain why A is correct?
because it updates every row. If it does not have a match it will put the value null
most likely customer table is PK. Orders table is FK. So it means the data that in the orders table also have in the customers table. And all rows will be updated.
I think B is correct, subquery will execute for each row its right but also update will update for each raw after fulfilling the condition of subquery :) Then how update will update each raw ? update will check its resources "subquery" is condition met ? yes ? then update after execute subquery and fully checking it.
The STATMENT update will execute first, then the action of updating will execute after the subquery. explain plan for update ordersQ8 o set customer_name = (select cust_last_name from customersQ8 where customer_id = o.customer_id); SELECT plan_table_output FROM TABLE(DBMS_XPLAN.DISPLAY('plan_table',null,'basic +note'));
AD is the answer
A nd D are correct