DB2 Error Code – -661 index index name cannot be created on partitioned tablespace tspace name because the number of part specifications is not equal to the number of partitions of the tablespace

In this post, you’ll learn about the error message -661 index index name cannot be created on partitioned tablespace tspace name because the number of part specifications is not equal to the number of partitions of the tablespace in the IBM DB2 database , the reason why it occurs along with the solution to fix it

IBM DB2 Error Message

-661 index index name cannot be created on partitioned tablespace tspace name because the number of part specifications is not equal to the number of partitions of the tablespace

Reason for the Error

The CREATE INDEX statement for the cluster index on a partitioned table (that is, a table residing in a partitioned table space) does not contain the same number of PART specifications as there are partitions in the table space. The definition for the cluster index for a partitioned table must contain exactly as many PART specifications as there are partitions in the table space in which that table resides. Also, the part numbers must be valid and unique.

Solution

Examine the definition of the partitioned table space to determine how many partitions have been specified, and then correct the syntax of the CREATE INDEX statement to provide the proper number of PART specifications.