1Z0-062 · Question #208
The HR.DEPARTMENTS table is the parent of the HR.EMPLOYEES table. The EMPLOYEES.DEPARTMENT_ID column has foreign key constraint with the ON DELETE CASCADE option that refers to the DEPARTMETS .DEPARTM
The correct answer is D. The transaction acquires a table lock only on the EMPLOYEES table. This lock enables other. When the child table's foreign key column lacks an index and a parent row is deleted with ON DELETE CASCADE, Oracle acquires a table-level lock on the child table to safely perform the cascade, not on the parent.
Question
The HR.DEPARTMENTS table is the parent of the HR.EMPLOYEES table. The EMPLOYEES.DEPARTMENT_ID column has foreign key constraint with the ON DELETE CASCADE option that refers to the DEPARTMETS .DEPARTMENT_ID column. An index exists on the DEPARTMETS.DEPARTMENT_ID column. A transaction deletes a primary key in the DEPARTMENTS table, which has child rows in the EMPLOYEES table. Which statement is true?
Options
- AThe transaction acquires a table lock only on the DEPARTMENTS table until the transaction is
- BOnly the rows that are deleted in the DEPARTMETS and EMPLOYEES tables are locked until the
- CThe transaction acquires a table lock only on the DEPARTMENTS table. This lock enables other
- DThe transaction acquires a table lock only on the EMPLOYEES table. This lock enables other
How the community answered
(38 responses)- A3% (1)
- B8% (3)
- C13% (5)
- D76% (29)
Why each option
When the child table's foreign key column lacks an index and a parent row is deleted with ON DELETE CASCADE, Oracle acquires a table-level lock on the child table to safely perform the cascade, not on the parent.
DEPARTMENTS does not receive a table lock; only the specific parent row being deleted receives a row-level lock, so a table lock exclusively on DEPARTMENTS is incorrect.
Row-level locking on both tables would apply only if an index existed on EMPLOYEES.DEPARTMENT_ID (the child FK column), enabling Oracle to identify and lock only the affected child rows; without that index, a full table lock on EMPLOYEES is required.
A table lock on DEPARTMENTS alone is incorrect; the table lock caused by a missing child FK index is placed on the child table (EMPLOYEES), not on the parent table from which the row is deleted.
The index mentioned in the question is on DEPARTMENTS.DEPARTMENT_ID (the parent primary key column), not on EMPLOYEES.DEPARTMENT_ID (the child FK column); without an index on the child FK column, Oracle cannot efficiently locate child rows and must acquire a table lock on EMPLOYEES to process the cascade delete while blocking conflicting DML from other sessions - this lock still permits reads on the EMPLOYEES table.
Concept tested: Oracle FK locking behavior without index on child FK column
Source: https://docs.oracle.com/database/121/CNCPT/consist.htm
Topics
Community Discussion
No community discussion yet for this question.