ORA-00001: unique constraint primary key violated

青春壹個敷衍的年華 提交于 2019-12-04 19:33:30
Dmitriy

If you have 'CREATE TABLE' privilege, use dbms_errlog package.

  1. Run script:

    begin
      dbms_errlog.create_error_log('DBO.T_LIAV_AGENT_STATE_APPROVAL');
    end;
    /
    
  2. Run your INSERT script with an additional clause:

    INSERT INTO dbo.T_LIAV_AGENT_STATE_APPROVAL
    SELECT ...
    FROM ...
    LOG ERRORS INTO err$_T_LIAV_AGENT_STATE_APPROVAL REJECT LIMIT UNLIMITED;
    
  3. Check error logging table for errors:

    select * from err$_T_LIAV_AGENT_STATE_APPROVAL;
    

You will see all records, that violated constraints, and error messages.

Select statement was missing a column when compared to Insert table statement so there was this error. When i added that column to the select statement it worked perfectly.

Shreya Srivastava

If you are not sure which unique constraint was violated, you can run the following SQL:

Select Distinct table_name
From all_indexes
Where index_name = 'CONSTRAINT_NAME';
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!