SQL Server and different types of lock

Hi

There are different types of lock in SQL Server 2000 and 2005. These locks are applied in different situations. Here is the list of locks and the situation for the locks.

SHARED - This lock is applied for read operation where the data is not updated. A good example would be the select statement.

UPDATE – This locked on those resources that can be updated. This lock prevents the common form of dead lock that occurs when multiple sessions are locking the data so that they can update it later.


EXCLUSIVE - Used for data-modification operations, such as INSERT, UPDATE, or DELETE. Ensures that multiple updates cannot be made to the same resource at the same time.

INTENT - Used to establish a lock hierarchy. The different types of intent locks are: intent shared, intent exclusive, and shared with intent exclusive.

SCHEMA - Used when an operation dependent on the schema of a table is executing. The different types of schema locks are: schema modification and schema stability.

BULK UPDATE – This lock is applied when there is a bulk copying of data and the TABLOCK is applied

KEY RANGE - Protects the range of rows read by a query when using the serializable transaction isolation level. Ensures that other transactions cannot insert rows that would qualify for the queries of the serializable transaction if the queries were run again.

Thanks
Vikram


Share this post   Email it |  digg it! |  reddit! |  bookmark it!

Feedback

Posted on 10/11/2007 9:27:51 PM

nice info thanks!

Posted on 12/13/2007 4:27:12 AM

hi vikram

can you tell me how to delete records without locking.

Posted on 12/20/2007 10:27:25 PM

nice info thanks!

Posted on 12/27/2007 5:59:46 AM

can u help me.
i want to lock table when inserting record in table in asp.net
using sqlserver2000.

i.e when one user inserting record in table say tblcompany at the same time other user inserting record in same table at that time i have to use lock.

Plz mail me the solution to mi yahoo id.

Posted on 9/18/2008 10:34:49 AM

Hi Vikram,
Good information Thank you.

Posted on 9/18/2008 10:38:28 AM

Hi Vikram,
Good information Thank you.

Please post your comments:

Name:  
Email (optional): Your email address will not be posted.
URL (optional):
Comments: HTML will be ignored, URLs will be converted to hyperlinks  
Enter the text you see in the box:
 
Copyright © 2006 - 2008 Vikram Lakhotia