View the Exhibit and examine the structure of ORDERS and ORDER_ITEMS tables.
ORDER_ID is the primary key in the ORDERS table. It is also the foreign key in the ORDER_ITEMS table wherein it is created with the ON DELETE
CASCADE option.
Which DELETE statement would execute successfully?
A. DELETE orders o, order_items I
WHERE o.order_id = i.order_id;
B. DELETE
FROM orders
WHERE (SELECT order_id
FROM order_items);
C. DELETE orders
WHERE order_total < 1000;
D. DELETE order_id
FROM orders
WHERE order_total < 1000;
ans c is right answer because when on delete cascade specified in order items table(which is child table
we remove from order table.(master table)
(the specified condition with delete matching rows are removed from
both tables order,order items.
All Questions is wrong.
how the fuck is providing those wrong answers , it is not B it’s C
Correct: C
but the syntax is DELETE FROM where ;
FROM keyword is not mandatory for the delete syntax.
Correct : C
C is still wrong if order_total has more than 1000.
C would execute successfully, so, is the correct answer.
It cannot be B, because any condition in the WHERE clause must evaluate to TRUE/FALSE. A select does not evaluate to TRUE/FALSE.
This would also execute successfully :
DELETE
FROM orders
WHERE order_id in (SELECT order_id
FROM order_items);