August 9, 2011 at 2:28 am
Hi All,
Want to know the basic difference between blocking and locking?
Thank You.
August 9, 2011 at 2:41 am
I think they cannot be compared.
Locking is an action taken by SQL Server engine to protect data integrity. For example when a row is being UPDATEd it is locked by the database engine to make sure that other users can't DELETE/UPDATE it at the same time.
Blocking is a situation where a process is waiting for another to release the lock.
August 9, 2011 at 3:01 am
While the are used synonymously there is the basic difference Suresh has just pointed out.
Usually Locking is the cause of blocking. Ie. One process is locking certain rows with exclusive locks for example and this in turn ins blocking another process from performing any kind of operation on those rows.
I guess your asking this as part of an interview question , so Sureshs answer would be good enough.
August 9, 2011 at 5:30 am
LOCKING occurs when connection needs access to a piece of data in database and itβs necessary for SQL Server when managing multiple connections
BLOCKING occurs when two connections need access to same piece of data concurrently and one connection is blocked because at a particular time, only one connection can have access
August 11, 2011 at 1:49 am
Thank you. π
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply