Start of change

Processing XML data with DB2 pureXML

You can use pureXML® with your client applications to manage XML data in DB2® tables. You can store well-formed XML documents in their hierarchical form and retrieve all or portions of those documents.

Because the stored XML data is fully integrated into the DB2 database system, you can access and manage the XML data by using DB2 functions and capabilities. XML data is stored in a separate table space from SQL data types. The underlying storage of XML data is transparent to the application.

How is XML data stored?

The XML column data type is provided for storage of XML data in DB2 tables. With SQL statements you can:

  • Create tables with XML columns.
  • Add XML columns to existing tables.
  • Create indexes over XML columns.
  • Create triggers on tables with XML columns.
  • Insert, update, or delete XML documents.

For details about the storage of XML data, see Storage structure for XML data.

What is the pureXML data model?

The pureXML data model provides an abstract representation of one or more XML documents or fragments. The purpose of the data model is to define all permissible values of expressions. The pureXML data model is described in terms of sequences and items, atomic values, and nodes. For details about the pureXML data model, see pureXML data model.

How is XML data represented in DB2?

The XML data type is used to define columns of a table that store XML values. This built-in data type enables you to store well-formed XML documents in a database. For details about the XML data type, see XML data type.

How do you retrieve information from an XML document?

XQuery is a generalized language for interpreting, retrieving, and modifying XML data. XQuery, SQL, or a combination of both can be used to query and update XML data. SQL functions that return XML data or take XML arguments (referred to as SQL/XML functions) also enable XML data to be constructed or published from values that are retrieved from the database. The XMLTABLE SQL/XML function returns a table from the evaluation of XQuery expressions. XPath is a subset of XQuery and can be used to retrieve XML data with a simpler query syntax. For details about retrieving XML data, see Retrieving XML data.

How can you update an XML document?

You can use SQL to update entire documents from XML columns, just as you retrieve data from any other type of column. You can also update entire or portions of documents with XQuery functions. For details about updating XML data, see Updates of XML columns.

How can you improve query performance to XML data?

Indexing support is available for data that is stored in XML columns. The use of indexes over XML data can improve the efficiency of queries that you issue against XML documents. An XML index differs from a relational index in that a relational index applies to an entire column, whereas an XML index applies to part of the data in a column. You indicate which parts of an XML column are indexed by specifying an XML pattern, which is a limited XPath expression. For details about indexing XML data, see XML data indexing.

What is XML schema validation?

An XML schema is used to validate and process XML documents. The XML schema repository (XSR) is a repository of XML schemas to process documents stored in XML columns with pureXML. For details about XML schema validation:

Which application development environments can you use?

Application development support of XML enables applications to combine XML and relational data access and storage. The following programming languages support the XML data type:
  • Assembler
  • C or C++ (embedded SQL or DB2 ODBC)
  • COBOL
  • Java (pureQuery®, JDBC, or SQLJ)
  • PL/I
  • SQL PL

Can you use DB2 utilities with XML data?

DB2 for z/OS utilities support the XML data type. The storage structure for XML data and indexes is like the storage structure for LOB data and indexes. As with LOB data, XML data is not stored in the base table space, but it is stored in separate table spaces that contain only XML data. The XML table spaces also have their own index spaces. Therefore, the implications of using utilities for manipulating, backing up, and restoring XML data and LOB data are similar. For details about how particular DB2 utilities interact with XML data, see XML support in DB2 utilities.

End of change