17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 14: Transactions and Locks<br />

Figure 14-3<br />

Setting the Isolation Le vel<br />

442<br />

We’ve seen that several different kinds of problems can be prevented by different locking strategies.<br />

We’ve also seen what kinds of locks are available and how they have an impact on the availability of<br />

resources. Now it’s time to take a closer look at how these process management pieces work together to<br />

ensure overall data integrity — to make certain that you can get the results you expect.<br />

The first thing to understand about the relationship between transactions and locks is that they are inextricably<br />

linked with each other. By default, any lock that is data modification related will, once created,<br />

be held for the duration of the transaction. If you have a long transaction, this means that your locks<br />

may be preventing other processes from accessing the objects you have a lock on for a rather long time.<br />

It probably goes without saying that this can be rather problematic.<br />

However, that’s only the default. In fact, there are actually five different isolation levels that you can set:<br />

❑ READ COMMITTED (the default)<br />

❑ READ UNCOMMITTED<br />

❑ REPEATABLE READ<br />

❑ SERIALIZABLE<br />

❑ SNAPSHOT

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!