XML in Db2

The XML standard has acquired a great impact on the IT industry and on the way we are working. It has become the standard for structured data transport, and is also more and more used to store documents in a format-neutral way. Questions that arise in a Db2 context are:

  • Are there easy ways to handle XML documents and store the data in Db2, and how can this be done without losing (structure) information?
  • Is it possible to create an XML document based on relational Db2 data, and can this be done by using SQL?
  • How does a Db2 specialist handle complex XML in the database? Can XML documents be efficiently searched through? Do we have to create indexes for that purpose? Is it possible to modify XML documents efficiently? How to write an SQL query that collects data from both XML documents and from relational tables?

In this course we will explain the features of XML in combination with Db2 and we will present some practical implementation scenarios. To this end we will learn to work with "PureXML", the "hybrid" database solution of Db2 (since version 9, both on z/OS and on LUW).


No public sessions are currently scheduled. We will be pleased to set up an on-site course or to schedule an extra public session (in case of a sufficient number of candidates). Interested? Please let us know.

Intended for

Db2 developers and DBAs.


Sufficient background knowledge of Db2 is needed (see courses Db2 for z/OS fundamentals course or Db2 for LUW fundamentals course). A thorough XML knowledge or experience is not necessary; some notions of XML (see e.g. XML concepts) will of course be an advantage.

Main topics

  • Introduction to XML:
  • Everything a Db2 developer or DBA should know about XML: elements, attributes, tree structure, DTDs, Schemas, ...
  • PureXML:
  • Storing XML documents in tables by using the new Db2 datatype "XML"
  • Create XML documents: the functions XMLElement, XMLForest, XMLConcat, XMLAgg, XMLDocument
  • Validating XML documents: XML Schemas and the Db2 schema repository
  • Efficient searching through and modifying of stored XML documents by using XPath: XMLExists, XMLQuery, and XMLModify
  • using XQuery and its FLWOR syntax
  • Storing XML documents:
  • Administration and maintenance of an XML tablespace
  • Defining indexes on an XML document
  • XML transport of Db2 data:
  • Focusing on the most important differences between relational data representation and the XML data model
  • Suggestions for sensibly combining of / converting between relational data and XML data; shredding.
  • Practice:
  • Each technique is illustrated in detail
  • Opportunity to try everything out through individual exercises

Training method

As no thorough XML knowledge or experience is required for this session, we'll start with a brief theoretical introduction to XML. Starting from this basic XML knowledge, it will be easy to understand the XML features provided by Db2. The theoretical explanation will be guided by demo's and exercises.


1 day.

Course leader

Peter Vanroose, Kris Van Thillo.