Skip to main content
ExLibris
  • Subscribe by RSS
  • Ex Libris Knowledge Center

    z602_id: "cannot CREATE UNIQUE INDEX; duplicate keys found"

    • Article Type: General
    • Product: Aleph
    • Product Version: 16.02

    Description:
    When you try to build the z602_id Oracle index, you get:.
    ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found. Why?

    Resolution:
    This SQL was used to locate duplicates:

    SQL> select f.Z602_REC_KEY, substr(f.Z602_SUB_LIBRARY,1,50) , substr(s.Z602_SUB_LIBRARY,1,50) from z602 f, z602 s where f.Z602_REC_KEY = s.Z602_REC_KEY and substr(f.Z602_SUB_LIBRARY,1,50) ^= substr(s.Z602_SUB_LIBRARY,1,50);

    And this to delete them (since we found that some had the ""LGMED" sublibrary, while the other in the pair lacked it).

    SQL> delete from z602 where z602_rec_key in (select z602_rec_key from z602 group by z602_rec_key having count(*) > 1) and Z602_SUB_LIBRARY not like '%MED%';

    You should back up the Z602 table with p_file_03 before performing any such delete.


    • Article last edited: 10/8/2013
    • Was this article helpful?