Cursors: which cursor type stores primary keys at open time and uses the keys to fetch the current row values later (so changes by others are visible)?

Difficulty: Medium

Correct Answer: Keyset

Explanation:


Introduction / Context:
Different cursor types balance stability versus currency of data. This question targets the cursor whose membership is fixed but values can reflect concurrent updates.



Given Data / Assumptions:

  • The cursor saves key values for identified rows when opened.
  • When fetching, the cursor uses those keys to read current values.
  • If a row is deleted, it becomes inaccessible; new rows are not added.


Concept / Approach:
A keyset cursor materializes the set of primary keys at open time. Data lookups at fetch time use those keys, so updates by other transactions are visible, deletions are detected, and inserts are not seen because the keyset is fixed.



Step-by-Step Solution:

Eliminate “static”: takes a snapshot; values do not change.Eliminate “forward only”: one-way movement; does not specify keyset behavior.Eliminate “dynamic”: membership and values can change; not just keyset.Select “Keyset”: fixed membership via stored keys; current values fetched.


Verification / Alternative check:
Vendor docs (e.g., SQL Server) describe keyset behavior exactly as stated: fixed row identity with live data values.



Why Other Options Are Wrong:

  • Static: both membership and values are static (snapshot).
  • Dynamic: both membership and values can change.
  • Forward only: movement characteristic, not value-currency behavior.


Common Pitfalls:
Confusing “dynamic” (membership can grow/shrink) with “keyset” (membership fixed, values current).



Final Answer:
Keyset

Discussion & Comments

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