QuestionQ23

VerifiedManipulating Data

View the Exhibit and review the descriptions of the PRODUCTS and SALES tables.

Question Image

PROD_ID is the primary key in the PRODUCTS table and a foreign key in the SALES table. You want to delete all rows from the PRODUCTS table for which no sale occurred during the last three years. Which is the valid DELETE statement?

Explanation

In Oracle, subtracting 3*365 from SYSDATE produces a date approximately three years before the current date. IN permits the subquery to return multiple PROD_ID values, and the predicate SYSDATE - 3*365 >= time_id identifies sales dated on or before that cutoff. A scalar = subquery is not appropriate when multiple sales rows can be returned.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!