QuestionQ170

VerifiedManaging Schema Objects

Examine the following schema information:

  1. EMPLOYEES.DEPARTMENT_ID has a foreign key that references DEPARTMENTS.DEPARTMENT_ID.
  2. EMP_VIEW is based on the EMPLOYEES and DEPARTMENTS tables.
  3. EMP_VIEW contains the columns EMPLOYEE_ID, EMPLOYEE_NAME, and DEPARTMENT_NAME.

You must add the new MANAGER_ID column from the EMPLOYEES table to the view so that each employee’s manager is shown.

Which statement accomplishes this?

Explanation

Adding MANAGER_ID changes the view’s defining SELECT list, so the view must be redefined with CREATE OR REPLACE VIEW. The replacement query retains the join between EMPLOYEES and DEPARTMENTS and projects MANAGER_ID. ALTER VIEW cannot change an existing view definition. Oracle documents that OR REPLACE re-creates an existing view and can change its definition.

Learn more

Community Discussion

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