In DB2 locking and concurrency control, which set of lock types correctly represents common DB2 data locks used at the row or page level?

Difficulty: Medium

Correct Answer: Shared locks, update locks, and exclusive locks that control read and write access to rows or pages.

Explanation:


Introduction / Context:
Lock types are central to understanding DB2 concurrency behavior. Interviewers often want to see whether candidates can name and explain major lock types such as shared, update, and exclusive locks. This question focuses on recognizing the correct set of logical lock types that DB2 applies at the row or page level to control concurrent access.


Given Data / Assumptions:

  • We are discussing DB2 database locks used to protect table data.
  • Locks can be taken at different granularities such as row, page, table, or tablespace.
  • The question is about common logical types, not every internal variation of lock state.


Concept / Approach:
At a high level, DB2 uses shared locks for read operations, exclusive locks for changes, and update locks as an intermediate state before a row is updated. There are also intent locks that signal potential locking intentions at higher levels. The correct answer must mention shared, update, and exclusive locks because these capture the most important behaviors seen by applications. Options that talk about operating system concepts or obscure imaginary lock names must be rejected.


Step-by-Step Solution:
Step 1: Recall that a shared lock allows concurrent readers but prevents writers from changing the locked resource. Step 2: Remember that an exclusive lock prevents other transactions from reading or writing the locked resource, ensuring isolated updates. Step 3: Note that an update lock is typically used when a row is read with the intention to update it, reducing deadlock risk by controlling lock conversion order. Step 4: Compare these concepts to the options and identify which option accurately lists these lock types. Step 5: Confirm that option A is consistent with DB2 documentation and common teaching about lock types.


Verification / Alternative check:
If you have used DB2 performance or monitoring tools, you may have seen lock type codes such as S, U, and X, which stand for shared, update, and exclusive. Documentation and training materials also consistently refer to these three as the primary lock types that matter at the row or page level. This cross check reinforces that option A is aligned with how DB2 presents its locking model.


Why Other Options Are Wrong:
Option B is wrong because DB2 does not formally define separate lock types named read, write, and delete, and locks are not limited to the table space level.
Option C is wrong because time, memory, and CPU locks are not DB2 data locks; they relate more to operating system resource management than to database concurrency.
Option D is wrong because backup, restore, and archive locks are not standard DB2 lock types for individual rows or pages; utilities may cause internal locks, but not with these conceptual names.


Common Pitfalls:
Students sometimes mix up operating system locking concepts with database locking mechanisms. Another mistake is to overlook update locks, assuming that only shared and exclusive locks exist. Understanding update locks is important because they help reduce deadlock scenarios in common patterns such as read then update. A firm grasp of these terms also provides a foundation for learning more advanced topics like isolation levels and lock escalation.


Final Answer:
The correct set of DB2 lock types is shared locks, update locks, and exclusive locks that control read and write access to rows or pages.

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion