Personal tools
You are here: Home DB2 How To's Primary Key duplication on insert
Navigation
Log in


Forgot your password?
 
Document Actions

Primary Key duplication on insert

Primary Keys Duplicated - You cannot insert new records due Duplicated PK.


If you are using "identity columns as generated" you have to reset the PK using the commands below:


1 - Find the PK max value:


db2 "select max(<COLUMN_PK_NAME>) from <table_name>"


2 - Restart the value of PK identity column using MAX PK VALUE + 1:

db2 "ALTER TABLE <table_name> ALTER COLUMN <column_name> RESTART WITH <column_max_value> + 1"




Security Awareness
Would you like your company to implement gamification into your security awareness program?





Polls