← All errors

SQLCODE -603

SQL0603 Unique index cannot be created because of duplicate keys

IBM message text
Unique index cannot be created because of duplicate keys.
SQLCODE
-603
SQLSTATE
23515

Most common cause

CREATE UNIQUE INDEX, or a UNIQUE constraint, on a table that already holds duplicate values for that key.

Other causes

  • Duplicates made of NULLs: UNIQUE WHERE NOT NULL can be used.

How to fix it

Find the duplicates with GROUP BY key HAVING COUNT(*) > 1, fix them and create the index again. The job log says which rows are duplicates.

Related errors

Text and codes from IBM documentation for 7.6. Checked on .