Indexes with partitioned tables
Indexes can be created as partitioned or nonpartitioned. A partitioned index creates an individual index for each partition. A nonpartitioned index is a single index spanning all partitions of the table.
Partitioned indexes allow you to take advantage of improved optimization of queries. If a unique index is partitioned, columns specified in the index must be the same or a superset of the data partition key.
Use the CREATE INDEX statement to create indexes on partitioned tables. To create an index for each partition, use the PARTITIONED clause.
CREATE INDEX PRODLIB.SAMPLEINDEX ON PRODLIB.PAYROLL(EMPNUM) PARTITIONEDTo create a single index that spans all partitions, use the NOT PARTITIONED clause.
CREATE INDEX PRODLIB.SAMPLEINDEX ON PRODLIB.PAYROLL(EMPNUM) NOT PARTITIONEDYou can only create a partitioned Encoded Vector Index (EVI) over a partitioned table. You cannot create a nonpartitioned EVI over a partitioned table.
In the CREATE INDEX statement in the SQL reference topic collection, you can find more information about creating indexes for partitioned tables.
When creating an SQL unique index, unique constraint, or primary key constraint for a partitioned table, the following restrictions apply:
- An index can be partitioned if the keys of the unique index are the same or a superset of the partitioned keys.
- If a unique index is created with the default value of NOT PARTITIONED, and the keys of the unique index are a superset of the partitioned keys, the unique index is created as partitioned. If, however, the user explicitly specifies NOT PARTITIONED, and the keys of the unique index are a superset of the partitioned keys, the unique index is created as not partitioned.
Parent topic:
Partitioned tables
Related concepts
Query performance and optimization
Related tasks
CREATE INDEX
Related reference
SQL reference