Labels

Thursday, 4 February 2016

SQL Server Isolation Levels

The below isolation levels are available in SQL Server

          1. Read Committed
          2. Read Un Commited
          3. Repeatable Read
          4. Serializable
          5. Snapshot

1. Read Committed :

Read Committed is the default transaction isolation level in SQL Server .
In Read Committed Select query will consider only committed value of a table i.e in case if any opened or uncommitted transactions are available on a table from any another sessions then select query will wait until these transactions completes.

2. Read Uncommitted :

Read Uncommitted also called as dirty reads because it doesn't wait for committed values on  a table.

Note : 

If you want to maintain "Read Committed " isolation level and required dirty reads for specific table then you can use with(nolock) in select query for the required tables. 

3. Repeatable Read :

Select query of the table that is used under transaction of isolation level "Repeatable Read " cannot be modified i.e it will allows insert new data but doesn't allow updates from any other sessions till transaction is completed.

4. Serializable :

Serializable is similar to Repeatable Read but the difference is it prevents phantom reads. It works based on range lock i.e if table has index then it locks records based on index range used in where clause . If the table doesn't have the index then it locks the complete table.

5. Snapshot :

Snapshot is similar to Serializable but the difference is snapshot is doesn't hold lock on table during the transaction so table can be modified in another sessions where as snapshot isolation maintains versioning in tempdb for old data in case of any data modification occurs in other sessions so that the existing transactions displays old data from tempdb.\


I hope the article was useful! and I need to let you know that this won’t stop here .keep in touch and feel free to ask any doubts related to this topic .


No comments:

Post a Comment