The isolation level associated with an application process defines the degree of isolation of that application process from other concurrently executing application processes. The isolation level of an application process, P, therefore specifies:
Isolation level is specified as an attribute of a package and applies to the application processes that use the package. The isolation level is specified in the program preparation process. Depending on the type of lock, this limits or prevents access to the data by concurrent application processes. For details on different types and attributes of specific locks refer to Administration Guide. The database manager supports three general categories of locks:
accessing the data in any way except for application processes with an isolation level of uncommitted read, which can read but not modify the data. (See Uncommitted Read (UR).)
The following descriptions of isolation levels refer to locking data in row units. Logically, locking occurs at the base table row. The database manager, however, can replace multiple row locks with a single table lock. This is called lock escalation. An application process is guaranteed at least the minimum requested lock level.
The DB2 Universal Database database manager supports four isolation levels. Regardless of the isolation level, the database manager places exclusive locks on every row that is inserted, updated, or deleted. Thus, all isolation levels ensure that any row that is changed by this application process during a unit of work is not changed by any other application processes until the unit of work is complete. The isolation levels are:
Level RR ensures that:
RR does not allow phantom rows (see Read Stability) to be seen.
In addition to any exclusive locks, an application process running at level RR acquires at least share locks on all the rows it references. Furthermore, the locking is performed so that the application process is completely isolated 6 from the effects of concurrent application processes.
Like level RR, level RS ensures that:
Unlike RR, RS does not completely isolate the application process from the effects of concurrent application processes. At level RS, application processes that issue the same query more than once might see additional rows. These additional rows are called phantom rows.
For example, a phantom row can occur in the following situation:
In addition to any exclusive locks, an application process running at level RS acquires at least share locks on all the qualifying rows.
Like the RR level:
Unlike the RR level:
In addition to any exclusive locks, an application process running at level CS has at least a share lock for the current row of every cursor.
For a SELECT INTO, FETCH with a read-only cursor, fullselect used in an INSERT, row fullselect in an UPDATE, or scalar fullselect (wherever used), level UR allows:
For other operations, the rules of level CS apply.
A comparison of the four isolation levels can be found on Appendix H, Comparison of Isolation Levels.