DB2 Version 9.7 for Linux, UNIX, and Windows

Importing XML data

The import utility can be used to import XML data into an XML table column using either the table name or a nickname for a DB2® Database for Linux, UNIX, and Windows source data object.

When importing data into an XML table column, you can use the XML FROM option to specify the paths of the input XML data file or files. For example, for an XML file "/home/user/xmlpath/xmldocs.001.xml" that had previously been exported, the following command could be used to import the data back into the table.
   IMPORT FROM t1export.del OF DEL XML FROM /home/user/xmlpath INSERT INTO USER.T1

Validating inserted documents against schemas

The XMLVALIDATE option allows XML documents to be validated against XML schemas as they are imported. In the following example, incoming XML documents are validated against schema information that was saved when the XML documents were exported:
   IMPORT FROM t1export.del OF DEL XML FROM /home/user/xmlpath XMLVALIDATE 
        USING XDS INSERT INTO USER.T1

Specifying parse options

You can use the XMLPARSE option to specify whether whitespace in the imported XML documents is preserved or stripped. In the following example, all imported XML documents are validated against XML schema information that was saved when the XML documents were exported, and these documents are parsed with whitespace preserved.
   IMPORT FROM t1export.del OF DEL XML FROM /home/user/xmlpath XMLPARSE PRESERVE 
   WHITESPACE XMLVALIDATE USING XDS INSERT INTO USER.T1