What resource does a key lock actually lock?

I know a key lock locks a key in an index. However, what does "key" actually mean?

For example, if I have a non-clustered index on a surname column and attempt an update where surname = "Jones", will I have effectively locked every row in the table where the surname is "Jones"? Or will the index be locked at a higher level, preventing access of rows with surnames other than "Jones"?

The reason I ask is this note in Books Online about Lock Granularity and Hierarchies:

KEY: A row lock within an index used to protect key ranges in serializable transactions.

This suggests a range of keys will be locked, not just one.

21
задан gotqn 7 November 2014 в 13:00
поделиться