SET INDEXES statement
Use the SET INDEXES statement to enable or disable a user-defined index, or to change the filtering mode of a unique index.
This statement is an extension to the ANSI/ISO standard for SQL.
Syntax
Element | Description | Restrictions | Syntax |
---|---|---|---|
index | Index to be enabled, disabled, or changed in its filtering mode | Must exist | Identifier |
table | Table whose indexes are all to be enabled, disabled, or changed in their filtering mode | Must exist | Identifier |
Usage
SET INDEXES FOR cust_calls DISABLED; SET INDEXES FOR cust_calls ENABLED;
This simple syntax can be convenient in operations where you intend to LOAD or TRUNCATE all the data in a table, or to consolidate the free space in a table.
Explicitly-defined and implicitly-defined indexes
The SET INDEXES statement operates on indexes that the CREATE INDEX statement created explicitly. It is not useful, however, with system-defined indexes that PRIMARY KEY or FOREIGN KEY constraint definitions create implicitly. The SET INDEXES statement cannot specify system-generated names that begin with the blank (ASCII 32) character, even if your database has the DELIMIDENT environment variable set to support double quotation marks as delimiters for database object identifiers.
SET CONSTRAINTS FOR cust_calls DISABLED; SET CONSTRAINTS FOR cust_calls ENABLED;
SET INDEXES FOR cust_calls DISABLED; SET CONSTRAINTS FOR cust_calls DISABLED;You can similarly enable all the explicitly-defined and implicitly-defined indexes of a table, without referencing the system-generated names of the implicitly-defined indexes, by substituting
ENABLED
for DISABLED
in
the examples above.The SET INDEXES statement is a special case of the SET Database Object Mode statement. The SET Database Object Mode statement can also enable or disable a trigger or constraint, or can change the filtering mode of constraints and unique indexes.
For the complete syntax and semantics of the SET INDEXES statement, see SET Database Object Mode statement.
Do not confuse the SET INDEXES statement with the SET INDEX statement, which was supported in releases earlier than Version 9.40. The HCL OneDB™ database server ignores the SET INDEX statement in current releases.
Restrictions on Secondary Servers
In cluster environments, the SET INDEXES statement is not supported on updatable secondary servers. (More generally, session-level index, trigger, and constraint modes that the SET Database Object Mode statement specifies are not redirected for UPDATE operations on table objects in databases of secondary servers.)