If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > auto-increment primary key jumped by over 2 million!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-01-05, 11:05
skinnywhitegeek skinnywhitegeek is offline
Registered User
 
Join Date: Jan 2002
Location: Nottingham, UK
Posts: 37
Question auto-increment primary key jumped by over 2 million!

Hi,

I'm wondering why the auto-increment primary key values in a mysql database table have jumped from 949 to 2147483648. That's a jump of over 2 million! Has anyone ever seen this happen?

I had to change the datatype from int(9) to bigint(20) just so the database could make new records in the table. Before I changed the datatype it was truncating the new value and then trying to generate an identically truncated value for the next primary key, thus causing a database error and drawing my attention. This has wreaked a good deal of havoc in my database, as the values are also a foreign key in another table, whose datatype I also realized had to be changed.

Thanks in advance for any light you may be able to shed onto this mysterious occurrence.

-G
__________________
----
system:
Mac Powerbook 1GHz
Reply With Quote
  #2 (permalink)  
Old 02-01-05, 13:51
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
probably what happened is that somebody/something inserted a negative value into the key

if it were me, i would have fixed the data error instead of altering the datatype

plus, there's no guarantee that the same underlying problem won't screw up your BIGINT values, and then you're cooked
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On