I have two databases – one is 11g and another 12c. 12c db has the exact data of 11g (expdp/impdp). Now I'm facing an error in one of the tables with unique constraint error. I have checked the structure of the table and constraints enabled for the table in both the databases, that is same as well. Now how can I sort this out? I'm facing this error on the application which is running on it, when I click one of the tabs.
Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-00001:unique constraint (USER1.HIGHT_PK) violated
is the error i'm getting
Unique constraint error Oracle
exportimportoracleoracle-12cunique-constraint
Related Question
- IMPDP Failing with ORA-00001: unique constraint in oracle
- Unique constraint violated
- How to set the sequence to the last used id for all tables in Oracle
- Sql-server – SQL Insert multiple values with UNIQUE constraint
- ORA-00001 – But no name
- How to catch all the errors happening during the execution of an SQL file containing multiple INSERT INTO statements to insert multiple rows
- ORA-39014 import in Oracle 19c from DMP file of Oracle12c
Best Answer
You wrote
But are you sure?
1) Did you make a consistent export of your tables? This means all table data is from the same point in time. For this it is sufficient that you stop all other write activity on the database during export. Or you set the flashback_scn parameter when using expdp or the consistent parameter when using exp.
2) Are your sequence value consistent with your table data? This means all table data and the state of the sequence is from the same point in time. For this it is sufficient that you stop all other read and write activity on the database during export. This is the only way i know to guarantee this consistency. I think that enen the flashback_scn or consistent parameters can't help here. They are useful for for transactional data only. I think the structures like sequences are extracted before the table data is read, here is the log from an export https://community.oracle.com/thread/3519031
Solution
If you didn't make a data consistent export (case 1) you should repeat the export with the appropriate [consistency parameter]. If you have a problem with the sequences (case 2) you can try the following. Recreate the sequences of the target database (where you have imported the schema) like the current sequences of the source database. Now all sequences produce values that weren't yet used by the application. Most application have no problems (should not have problems) if there are gaps in the series of sequence numbers.