XML IN THE DATABASE: THE XML DATA TYPE Creating an Index on an XML Column You can create indexes on an XML column, using approximately the same syntax that you use for a SQL index. Four kinds of XML indexes can be created. In order to create any kind of XML index, the table must have an ordinary SQL data type primary key column. You must first create the primary index or node table. This index associates each node with the SQL key column and is useful for ad hoc queries. You can create an XML index over only the document structure, using the FOR PATH keyword. This is similar to the concept of creating a key in XSLT; this type of index helps in XQuery path statements. You can also create an index only over the values of the elements and attributes in the XMLdata type column with the FOR VALUE keyword. This type of index can help in XQuery content searches. The FOR PROPERTY keyword creates an index that is most usable when your XML consists of a shallow hierarchy with many elements or attributes that are really name/value pairs. Additional XML index types may be defined in the future. If you create an XML index on the entire document or column, you cannot index subsets of the document. The syntax is shown in Listing 8-6. Listing 8-6: Creating XML Indexes CREATE TABLE xml_tab( the_id INTEGER PRIMARY_KEY IDENTITY, xml_col XML) GO CREATE PRIMARY XML INDEX xmlidx1 ON xml_tab(xml_col) GO structural index CREATE XML INDEX xmls1 ON xml_tab(xml_col) USING XML INDEX xmlidx1 FOR PATH GO property index CREATE XML INDEX xmlp1 ON xml_tab(xml_col) USING XML INDEX xmlidx1 FOR PROPERTY GO value index CREATE XML INDEX xmlv1 ON xml_tab(xml_col) USING XML INDEX xmlidx1 FOR VALUE GO

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services

Bookmark the permalink.

Comments are closed.