60 Extremely pureXML in DB2 10 for z/OS
4.3 Multiple version concurrency control for XML
DB2 supports multiple versions of an XML document in an XML column if the base table
space
for the table that contains the XML column is also a universal table space and created
in DB2 10 NFM
. All XML columns in the table support multiple versions.
With XML versions, when you insert an XML document into an XML column, DB2 assigns a
version number to the XML document. If the entire XML document is updated, DB2 creates a
new version of the document in the XML table. If a portion of the XML document is updated,
DB2 creates a new version of the updated portion. When DB2 uses XML versions, more data
set space is required than when versions are not used. However, DB2 periodically deletes
versions that are no longer needed. In addition, you can run the REORG utility against the
XML table space that contains the XML document to remove unneeded versions. DB2
removes versions of a document when update operations that require the versions are
committed, and when no readers reference the unneeded versions.
4.3.1 Example of improved concurrency with XML versions
This example demonstrates how multiple XML versions can improve concurrency when the
same XML documents are modified multiple times within the same transaction.
Suppose that table T1, which is in a universal table space, is defined as follows:
CREATE TABLE T1(
INT1 INT,
XML1 XML,
XML2 XML );
Table 4-1 shows the data in table T1.
Table 4-1 Data in table T1
An application performs SQL read operations that are represented by the following
pseudocode:
EXEC SQL
DECLARE CURSOR C1 FOR
SELECT INT1, XML1
Support: If the base table space is not a universal table space, it does not support multiple
XML versions. To convert the base table space from either segmented or partitioned to
universal table space, you must remove it (with the DROP command) and re-create it.
ALTER and REORG are not sufficient in this case.
XML versions: XML versions differ from table space versions or index versions. The
purpose of XML versions is to optimize concurrency and memory usage. The purpose of
table space and index versions is to maximize data availability.
INT1 XML1 XML2
350 <A1>111</A1> <A2>aaa</A2>
100 <A1>111</A1> <A2>aaa</A2>
250 <A1>111</A1> <A2>aaa</A2>

Get Extremely pureXML in DB2 10 for z/OS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.