Prerequisites:
Your DB2 database must support XML
//-------------------------
Exercise 1 describes how to set up a DB2 database with a UTF-8 code set.
Prepare DB2-Td ~ in the system command processor Window ~ Command to call the DB2 command line processor. -The TD option specifies the font size (~) As the statement termination character, rather than the default semicolon (;) character. Select the termination character instead of the semicolon to ensure that the statements or queries declared using the namespace are not incorrectly interpreted. The namespace statement is terminated with a semicolon. (Used in the examples in this tutorial ~ Terminator ). On Windows (R), run the db2cmd command to initialize the DB2 command line environment. You can input or copy the example of this exercise in interactive mode and paste it to the DB2 command processor. You can also use the command editor to issue commands and statements interactively. Namespace: If the XML document stored in the database contains a namespace, all operations related to querying and specifying a namespace (for example, using the create index statement to create an index on XML data) you must declare the same namespace to produce the expected results. This requirement is the standard namespace action specified by the XML specification. Exercise 1: Create a DB2 database and table that can store XML data this exercise shows how to create a database named xmltut and a table containing XML columns using the UTF-8 code set. You must create a table that contains XML columns in a database that is defined with the UTF-8 code set and compatible zone code. To create a database that can store XML data, issue the following command to create a database named xmltut with the UTF-8 code set: Create Database xmltut using codeset UTF-8 territory us ~ By default, automatic storage is enabled when you create a database. Automatic Storage improves performance and facilitates XML data management, because it generates a database hosting space (DMS) Table space that can be expanded as needed. Connect to the database: connect to xmltut ~ Now you can create a table named "customer" and containing an XML column: Create Table customer (CID bigint not null primary key, info XML )~ Note that the specified Primary Key is optional and it is not required to store or compile XML indexes. You can also use the alter table SQL statement to add one or more XML columns to an existing table in the UTF-8 database.