Examine the structure of the EMPLOYEES and NEW_EMPLOYEES tables: EMPLOYEES ---------- EMPLOYEE_ID NUMBER Primary Key FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25) HIRE_DATE DATE NEW_EMPLOYEES -------------- EMPLOYEE_ID NUMBER Primary Key NAME VARCHAR2(25) Which DELETE Statement is valid?

  1. Delete from employees where employee_id = (select employee_id from employees);

  2. Delete * from employees where employee_id = (select employee_id from new_employees);

  3. Delete from employees where employee_id in (select employee_id from new_employees where name = 'Carrey');

  4. Delete * from Employees where employee_id in (select employee_id from new_employees where last_name = 'Carrey');


Correct Option: C

AI Explanation

To answer this question, let's examine each DELETE statement and determine if it is valid or not:

A. Delete from employees where employee_id = (select employee_id from employees); This statement is not valid because it attempts to delete rows from the same table that it is querying (EMPLOYEES).

B. Delete * from employees where employee_id = (select employee_id from new_employees); This statement is not valid because the "DELETE" keyword should not be followed by an asterisk (*). It should be "DELETE FROM" instead.

C. Delete from employees where employee_id in (select employee_id from new_employees where name = 'Carrey'); This statement is valid. It deletes rows from the EMPLOYEES table where the employee_id is present in the result of the subquery.

D. Delete * from Employees where employee_id in (select employee_id from new_employees where last_name = 'Carrey'); This statement is not valid because, similar to option B, the "DELETE" keyword should not be followed by an asterisk (*). It should be "DELETE FROM" instead.

The correct answer is C. This statement is valid because it uses the correct syntax and deletes rows from the EMPLOYEES table based on a condition specified in the subquery.

Find more quizzes: