Duplicate key violates unique constraint

This occurs in, after the .sql file into the local postgresql database, then create or update data when being given:

Unique violation: 7 ERROR: duplicate key violates unique constraint "table_name_pkey" 

Solution:
1. Check the maximum error id own table
2. Run the navicate in: Select nextval ( 'table_name_id_seq') command to view the increment of the current sequence value table What is
3. general If you can read this article, explain your sequence increment value must be greater than the maximum table the above mentioned id
4. executed in navicate in: Select setval ( 'table_name_id_seq', " write the table where the maximum id + 1 value ")
these four steps to complete the problem immediately perfect solution! ! ! ! !

Guess you like

Origin www.cnblogs.com/qaing123/p/11027174.html