nerdexam
Oracle

1Z0-052 · Question #222

View the Exhibit to see the structure of the EMPLOYEES and DEPARTMENTS tables. Your organization plans to dissolve the department with department ID 30. You execute the following command to delete…

The correct answer is B. alter the foreign key constraint to include the on delete cascade option F. first, delete rows from the EMPLOYEES table for department id 30 and then delete the rows from. ORA-02292 occurs when a parent row cannot be deleted because child rows exist; you must either handle child rows first or configure the constraint to cascade deletes automatically.

Managing Data and Concurrency

Question

View the Exhibit to see the structure of the EMPLOYEES and DEPARTMENTS tables. Your organization plans to dissolve the department with department ID 30. You execute the following command to delete rows from the DEPARTMENTS table:

SQL>delete from DEPARTMENTS where DEPT_ID = 30; The command fails and displays the following error:

ERROR at line 1:

ORA-02292: integrity constraint (HR.SYS_C005374) violated - child record found Which two actions would you take to overcome this error? (Choose two.)

Exhibit

1Z0-052 question #222 exhibit

Options

  • Aalter the foreign key constraint to include the cascade option
  • Balter the foreign key constraint to include the on delete cascade option
  • Cfirst, drop the EMPLOYEES table and then delete the rows from the DEPARTMENTS table
  • Dfirst, drop the DEPARTMENTS table and then delete the rows from the EMPLOYEES table
  • Efirst, delete all of the rows from EMPLOYEES table and then delete the rows from the
  • Ffirst, delete rows from the EMPLOYEES table for department id 30 and then delete the rows from

How the community answered

(23 responses)
  • A
    4% (1)
  • B
    70% (16)
  • C
    17% (4)
  • E
    9% (2)

Why each option

ORA-02292 occurs when a parent row cannot be deleted because child rows exist; you must either handle child rows first or configure the constraint to cascade deletes automatically.

Aalter the foreign key constraint to include the cascade option

There is no plain 'cascade option' for a foreign key constraint in Oracle; the correct syntax is specifically ON DELETE CASCADE, making this option technically inaccurate.

Balter the foreign key constraint to include the on delete cascade optionCorrect

Altering the foreign key to include ON DELETE CASCADE causes Oracle to automatically delete all child rows in EMPLOYEES when the referenced row in DEPARTMENTS is deleted, resolving the constraint violation persistently via a DDL change to the constraint definition.

Cfirst, drop the EMPLOYEES table and then delete the rows from the DEPARTMENTS table

Dropping the entire EMPLOYEES table destroys all employee data across all departments, which is excessively destructive and far beyond the requirement of removing department 30.

Dfirst, drop the DEPARTMENTS table and then delete the rows from the EMPLOYEES table

Dropping the DEPARTMENTS table first is not possible while child rows in EMPLOYEES still reference it, and it would destroy parent data rather than resolving the constraint properly.

Efirst, delete all of the rows from EMPLOYEES table and then delete the rows from the

Deleting all rows from the EMPLOYEES table removes data for all departments, not just department 30, causing unacceptable data loss beyond the stated business requirement.

Ffirst, delete rows from the EMPLOYEES table for department id 30 and then delete the rows fromCorrect

Manually deleting the EMPLOYEES rows for department_id 30 first removes all child records before the parent delete, satisfying the referential integrity constraint and allowing the DEPARTMENTS delete to succeed without modifying the constraint.

Concept tested: Oracle referential integrity and ON DELETE CASCADE foreign key constraint

Source: https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/constraint.html

Topics

#foreign key constraints#referential integrity#cascade delete#DML errors

Community Discussion

No community discussion yet for this question.

Full 1Z0-052 Practice