开发者

MySQL copying over auto increment primary IDs

开发者 https://www.devze.com 2023-03-26 15:11 出处:网络
I have an old database where I want to copy the entire row into a new table, but开发者_运维技巧 preserve the original id column (which is a primary/autoincrement field)

I have an old database where I want to copy the entire row into a new table, but开发者_运维技巧 preserve the original id column (which is a primary/autoincrement field)

It seems to insert one row and then stop saying:

ERROR 1062 (23000): Duplicate entry '2' for key 'PRIMARY'

Am I missing some constraint issue/autoincrement not liking me explicitly choose the id #? Thanks for the help!


You are trying a row with ID of 2 when there is already a row in the table with an ID of 2. You can choose your own ID numbers as long as they're unique.

0

精彩评论

暂无评论...
验证码 换一张
取 消