1Z0-052 · Question #35
User A executes the following command to drop a large table in your database: SQL> DROP TABLE trans; While the drop table operation is in progress; user B executes the following command on the same…
The correct answer is C. It fails to delete the records because the table is locked in EXCLUSIVE mode. A DROP TABLE DDL operation holds an exclusive lock on the table, blocking any concurrent DML such as DELETE from acquiring the necessary lock and causing it to fail immediately.
Question
User A executes the following command to drop a large table in your database:
SQL> DROP TABLE trans; While the drop table operation is in progress; user B executes the following command on the same table; SQL> DELETE FROM trans WHERE tr_type='SL'; Which statement is true regarding the DELETE command?
Options
- AIt fails to delete the records because the records are locked in the SHARE mode
- BIt deletes the rows successfully because the table is locked in the SHARE mod
- CIt fails to delete the records because the table is locked in EXCLUSIVE mode
- DIt deletes the rows successfully because the table is locked in SHARE ROW EXCLUSIVE mode
How the community answered
(46 responses)- A4% (2)
- B13% (6)
- C59% (27)
- D24% (11)
Why each option
A DROP TABLE DDL operation holds an exclusive lock on the table, blocking any concurrent DML such as DELETE from acquiring the necessary lock and causing it to fail immediately.
DROP TABLE does not acquire a SHARE mode lock; it acquires a full EXCLUSIVE lock, making the stated lock type incorrect.
A SHARE mode lock would allow certain concurrent reads but not DML; however, this premise is false because DROP TABLE uses EXCLUSIVE mode, not SHARE mode.
DDL statements like DROP TABLE acquire an exclusive (X) lock on the table object, which is incompatible with every other lock mode; user B's DELETE cannot obtain the required row-exclusive lock and will receive an error rather than wait or succeed.
SHARE ROW EXCLUSIVE is a specific lock mode used by certain commands such as LOCK TABLE ... IN SHARE ROW EXCLUSIVE MODE; DROP TABLE uses a full EXCLUSIVE lock instead.
Concept tested: Oracle DDL exclusive locking blocking concurrent DML
Source: https://docs.oracle.com/en/database/oracle/oracle-database/19/cncpt/data-concurrency-and-consistency.html
Topics
Community Discussion
No community discussion yet for this question.