Db2 12 for Z/OS: Purexml Guide Chapter 1
Total Page:16
File Type:pdf, Size:1020Kb
Db2 12 for z/OS pureXML Guide IBM SC27-8862-02 Notes Before using this information and the product it supports, be sure to read the general information under "Notices" at the end of this information. Subsequent editions of this PDF will not be delivered in IBM Publications Center. Always download the latest edition from PDF format manuals for Db2 12 for z/OS (Db2 for z/OS Knowledge Center). 2020-12-16 edition This edition applies to Db2® 12 for z/OS® (product number 5650-DB2), Db2 12 for z/OS Value Unit Edition (product number 5770-AF3), and to any subsequent releases until otherwise indicated in new editions. Make sure you are using the correct edition for the level of the product. Specific changes are indicated by a vertical bar to the left of a change. A vertical bar to the left of a figure caption indicates that the figure has changed. Editorial changes that have no technical significance are not noted. © Copyright International Business Machines Corporation 2007, 2019. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents About this information.......................................................................................... ix Who should read this information................................................................................................................x Db2 Utilities Suite for z/OS...........................................................................................................................x Terminology and citations............................................................................................................................x Accessibility features for Db2 12 for z/OS..................................................................................................xi How to send your comments...................................................................................................................... xi How to read syntax diagrams......................................................................................................................xi Chapter 1. Overview of pureXML............................................................................ 1 pureXML data model ................................................................................................................................... 2 Sequences and items............................................................................................................................. 2 Atomic values......................................................................................................................................... 3 Nodes......................................................................................................................................................3 Data model generation in XQuery........................................................................................................12 Comparison of the XML model and the relational model......................................................................... 13 XML data type............................................................................................................................................ 14 Tutorial: Working with XML data................................................................................................................15 Prerequisites for using pureXML............................................................................................................... 18 Setting up the XML schema repository................................................................................................18 Chapter 2. Working with XML data....................................................................... 29 Creation of tables with XML columns........................................................................................................29 Altering tables with XML columns............................................................................................................. 29 Storage structure for XML data..................................................................................................................31 Insertion of rows with XML column values............................................................................................... 34 Updates of XML columns........................................................................................................................... 36 Updates of entire XML documents.......................................................................................................37 Partial updates of XML documents......................................................................................................38 Deletion of rows with XML documents from tables.................................................................................. 43 XML versions.............................................................................................................................................. 43 XML support in triggers..............................................................................................................................45 XML parsing................................................................................................................................................46 XML parsing and whitespace handling................................................................................................ 47 XML parsing and DTDs..........................................................................................................................48 XML schema validation.............................................................................................................................. 50 XML schema validation and ignorable whitespace............................................................................. 50 XML schema validation with an XML type modifier.............................................................................51 XML schema validation with DSN_XMLVALIDATE...............................................................................57 How to determine whether an XML document has been validated....................................................61 Casts between XML data types and SQL data types.................................................................................61 Examples of casts from XML schema data types to SQL data types.................................................. 62 Retrieving XML data................................................................................................................................... 65 Retrieval of an entire XML document from an XML column................................................................65 XMLQUERY function for retrieval of portions of an XML document.................................................... 65 XMLEXISTS predicate for querying XML data......................................................................................68 Constant and parameter marker passing to XMLEXISTS and XMLQUERY......................................... 69 XMLTABLE function for returning XQuery results as a table............................................................... 69 XML support in native SQL routines.....................................................................................................74 Requests for data in XML columns by earlier Db2 clients...................................................................77 Functions for constructing XML values..................................................................................................... 77 iii Special character handling in SQL/XML publishing functions.................................................................. 81 XML serialization........................................................................................................................................81 Differences in an XML document after storage and retrieval................................................................... 83 Transforming an XML document with XSLTRANSFORM........................................................................... 85 Chapter 3. XML data indexing...............................................................................87 Pattern expressions................................................................................................................................... 88 Namespace declarations in XML index definitions................................................................................... 89 Data types associated with pattern expressions...................................................................................... 90 XML schemas and XML indexes.................................................................................................................90 The UNIQUE keyword in an XML index definition..................................................................................... 91 Access methods with XML indexes........................................................................................................... 92 Examples of DOCID single index access (ACCESSTYPE='DX' only)....................................................93 Example of DOCID ANDing access (ACCESSTYPE='DI')..................................................................... 95 Example of DOCID ORing access (ACCESSTYPE='DU').......................................................................96 Examples of index