Previous Topic Next topic Print topic


X051: Duplicate key value when creating unique index indexname.

To fix this problem, drop this index and then test for duplicates using the following query:

SELECT index-field-list FROM table-name GROUP BY index-field-list HAVING count(*) > 1

where index-field-list is the list of the columns in the index you are trying to create, and table-name is the name of the table you are indexing. The rows retrieved correspond to duplicate entries that prevent you from creating a unique index on the specified fields.

If duplicates are found, perform a SELECT * from the table where values equal those of the results that come from the previous query and delete the additional entry rebuild index after dropping duplicates. If no records are retrieved, there are no duplicates.

Previous Topic Next topic Print topic