示例:对 XML 属性建立索引

这些示例基于以下三行数据:
<boat><name reg="hmc">titanic</name></boat>

<airplane callsign="qofz">kittyhawk</airplane>

<boat><name reg="CAN">Spirit of Canada</name></boat>

示例 1:比较 all_xmltags 和 all_xmlattrs

以下 CREATE INDEX 语句使用 all_xmltags 参数:
CREATE INDEX bts_idx ON bts_100_tab(col2 bts_nvarchar_ops) 
              USING bts(all_xmltags="yes") IN bts_sbspace1 ;
此索引使用以下字段表示标记类型:
airplane
name
相反,以下 CREATE INDEX 语句使用 all_xmlattrs 参数,而不是 all_xmltags 参数:
CREATE INDEX bts_idx ON bts_100_tab(col2 bts_nvarchar_ops) 
              USING bts(all_xmlattrs="yes") IN bts_sbspace1 ;
此索引使用以下字段表示标记属性:
@callsign
@reg

示例 2:组合使用 all_xmlattrs 和 all_xmltags

以下 CREATE INDEX 语句同时使用 all_xmlattrsall_xmltags 参数:
CREATE INDEX bts_idx ON bts_100_tab(col2 bts_nvarchar_ops) 
              USING bts(all_xmlattrs="yes",
                                   all_xmltags="yes") IN bts_sbspace1 ;
此索引使用以下字段表示标记类型和标记属性:
@callsign
@reg
airplane
name

示例 3:组合使用 all_xmlattrs、all_xmltags 和 xmlpath_processing

以下 CREATE INDEX 语句使用 all_xmlattrsall_xmltagsxmlpath_processing 参数:

CREATE INDEX bts_idx ON bts_100_tab(col2 bts_nvarchar_ops) 
                USING bts(xmlpath_processing="yes",
                                    all_xmlattrs="yes",
                                    all_xmltags="yes") IN bts_sbspace1 ;
此索引使用以下字段表示标记和属性的完整路径:
/airplane
/airplane@callsign
/boat/name
/boat/name@reg

示例 4:比较 all_xmltags 和 all_xmlattrs(同时带有 xmlpath_processing)

以下 CREATE INDEX 语句使用 all_xmltags 参数与 xmlpath_processing 参数:
CREATE INDEX bts_idx ON bts_100_tab(col2 bts_nvarchar_ops) 
                USING bts(xmlpath_processing="yes",
                                    all_xmltags="yes") IN bts_sbspace1 ;
此索引使用以下字段表示标记的路径:
/airplane
/boat/name
以下 CREATE INDEX 语句使用 all_xmlattrs 参数与 xmlpath_processing 参数:
CREATE INDEX bts_idx ON bts_100_tab(col2 bts_nvarchar_ops) 
                USING bts(xmlpath_processing="yes",
                                  all_xmlattrs="yes") IN bts_sbspace1 ;
此索引使用以下字段表示属性的路径:
/airplane@callsign
/boat/name@reg