16.10.2015 Views

Getting Started with DB2 Express-C

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

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

220 <strong>Getting</strong> <strong>Started</strong> <strong>with</strong> <strong>DB2</strong> <strong>Express</strong>-C<br />

Figure 13.7 – Phantom read<br />

Figure 13.7 shows the following sequence of events:<br />

1. App1 opens a cursor<br />

2. App2 adds a row to the database that would qualify for the cursor<br />

3. App2 commits changes<br />

4. App1 closes and reopens cursor<br />

In this case, App1 would not get the same data on a repeated read, it would get more rows,<br />

that’s why this problem is called “phantom read”.<br />

13.4 Isolation Levels<br />

You can think of isolation levels as locking policies where, depending on the isolation level<br />

chosen, you may get different behaviors for database locking <strong>with</strong> an application.<br />

<strong>DB2</strong> provides different levels of protection to isolate data:<br />

• Uncommitted Read (UR)<br />

• Cursor Stability (CS)<br />

• Read Stability (RS)<br />

• Repeatable Read (RR)<br />

13.4.1 Uncommitted read<br />

Uncommitted read is also known as dirty read. It is the lowest level of isolation, and<br />

provides the highest degree of concurrency. No row locks are obtained on read operations,<br />

unless another application attempts to drop or alter a table; and update operations act as if<br />

using the cursor stability isolation level.

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

Saved successfully!

Ooh no, something went wrong!