ALTER INDEX (Selective XML Indexes)
Modifies an existing selective XML index. The ALTER INDEX statement changes one or more of the following items:
-
The list of indexed paths (FOR clause).
-
The list of namespaces (WITH XMLNAMESPACES clause).
-
The index options (WITH clause).
For more information, see the following topics:
You cannot alter secondary selective XML indexes. For more information, see Create, Alter, and Drop Secondary Selective XML Indexes.
ALTER INDEX index_name
ON <table_object>
[WITH XMLNAMESPACES (<xmlnamespace_list>)]
FOR (<promoted_node_path_action_list>)
[WITH (<index_options>)]
<table_object> ::= { [ database_name. [ schema_name ] . | schema_name. ] table_name }
<promoted_node_path_action_list> ::= <promoted_node_path_action_item> [, <promoted_node_path_action_list>]
<promoted_node_path_action_item>::= <add_node_path_item_action> | <remove_node_path_item_action>
<add_node_path_item_action> ::= ADD <path_name> = <promoted_node_path_item>
<promoted_node_path_item>::=<xquery_node_path_item> | <sql_values_node_path_item>
<remove_node_path_item_action> ::= REMOVE <path_name>
<path_name_or_typed_node_path>::= <path_name> | <typed_node_path>
<typed_node_path> ::= <node_path> [[as XQUERY <xsd_type_ext>] | [as SQL <sql_type>]]
<xquery_node_path_item> ::= <node_path> [as XQUERY <xsd_type_or_node_hint>] [SINGLETON]
<xsd_type_or_node_hint> ::= [<xsd_type>] [MAXLENGTH(x)] | 'node()'
<sql_values_node_path_item> ::= <node_path> as SQL <sql_type> [SINGLETON]
<node_path> ::= <character_string_literal>
<xsd_type_ext> ::= <character_string_literal>
<sql_type> ::= <identifier>
<path_name> ::= <identifier>
<xmlnamespace_list> ::= <xmlnamespace_item> [, <xmlnamespace_list>]
<xmlnamespace_item> ::= <xmlnamespace_uri> AS <xmlnamespace_prefix>
<xml_namespace_uri> ::= <character_string_literal>
<xml_namespace_prefix> ::= <identifier>
<index_options ::= (
| PAD_INDEX = { ON | OFF }
| FILLFACTOR = fillfactor
| SORT_IN_TEMPDB = { ON | OFF }
| IGNORE_DUP_KEY =OFF
| DROP_EXISTING = { ON | OFF }
| ONLINE =OFF
| ALLOW_ROW_LOCKS = { ON | OFF }
| ALLOW_PAGE_LOCKS = { ON | OFF }
| MAXDOP = max_degree_of_parallelism
)
The following example shows an ALTER INDEX statement. This statement adds the path '/a/b/m' to the XQuery part of the index and deletes the path '/a/b/e' from the SQL part of the index created in the example in the topic CREATE SELECTIVE XML INDEX. The path to delete is identified by the name that was given to it when it was created.
ALTER INDEX sxi_index
ON Tbl
FOR
(
ADD pathm = '/a/b/m' as XQUERY 'node()' ,
REMOVE pathabe
)
The following example shows an ALTER INDEX statement that specifies index options. Index options are permitted because the statement does not use a FOR clause to add or remove paths.
ALTER INDEX sxi_index ON Tbl PAD_INDEX = ON
