I'm using a MySQL database. I have set an auto_increment function on "ID" column (which is also set as Primary key).

What will happen when it reaches its maximum possible value, according to the data type set for that column?

Can someone help me out what to do in such cases? Will it be handled automatically? Or will I have to handle it?


While inserting single record (by both INSERT .. VALUES and INSERT .. SELECT) you will obtain

Duplicate entry 'max_value_for_datatype' for key 'PRIMARY'

While inserting multiple records you will obtain (even when only one of them causes overflow)

Failed to read auto-increment value from storage engine


Will it be handled automatically?

No. You must handle it - and the best way is to solve this issue before it occures.

PS. If you are interested in to know what messages will be produced while inserting record(s) by LOAD DATA/XML you may test it by yourelf.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.