Re: MySQL ID -- what happens when you run out of range?

From: Date: Mon, 25 Jan 2010 21:51:54 +0000
Subject: Re: MySQL ID -- what happens when you run out of range?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-301421@lists.php.net to get a copy of this message
That is incorrect. What will happen is as follows: 1. The value will be incremented by 1 causing the value to be greater than the maximum integer allowed. 2. MySQL will see this as a problem and "truncate" it to the closest value. 3. MySQL will then try and insert the new row with the updated id. 4. MySQL will find that the id already exists, and will return a duplicate ID error. If you want to verify what occurs, create a table with a tinyint value for the id and autoincrement it. It is correct also, that you cannot use negative numbers for the autoincrement field. Camilo Sperberg wrote:
On Mon, Jan 25, 2010 at 17:15, Parham Doustdar <parham90@gmail.com> wrote:
Hello there, A friend called me today and was wondering what happens if the ID colomn of an MYSQL database, set to autoinc reaches the int limit. Will it return and begin choosing the ID's that have been deleted, or... what? Thanks!
    
from what I know, MySQL will convert that number into a negative number, which would be invalid for an auto-increment field (auto-increment == unsigned). That would raise an error ;) Greetings :)


« previous php.general (#301421) next »