[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: insert + AUTO_INCREMENT



Joris Kluivers wrote:
> 
> hi,
> 
> i have a problem
> i have a database table created with the statement:
> CREATE TABLE chatmessages (id tinyint(6) DEFAULT '0' NOT NULL AUTO_INCREMENT, message text, username varchar(100), UNIQUE id (id);
> 
> I insert records with:
> INSERT INTO chatmessages (message, username) VALUES ('this is my message', 'joris');
> 
> this works fine (for a while), i can insert messages and retreive them with php.
> But after some time i get the error:
> ERROR 1062: Duplicate entry '127' for key 1
> but how can this be because i've set it to AUTO_INCREMENT.

Using field type TINYINT for the id isn't a good idea, because the value
range for this field type is -128 to 127. So is you have more than 128
records, there are no ids left. AUTO_INCREMNT starts at 0.

Robert

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <mysql-thread67350@xxxxxxxxxxxxxxx>
To unsubscribe, e-mail <mysql-unsubscribe-treed=ultraviolet.org@xxxxxxxxxxxxxxx>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



This mailing list archive is a service of Copilot Consulting.