View Full Version : auto_increment question
jpmad4it
01-28-2006, 12:17 PM
hey
So i have a database that has been hammered by spammers in the past and the ID primary key field is auto_incrementing. Due to the spam the ID value has reached 2000 or something daft. The problem is that when users now enter legitamate info. to my database the auto increment continues from 2000 onwards, so the next value would be 2001 - but i want to it to continue from 24 onwards. Am i making sense?!?
My question is how do i get the database to automatically increment the ID field from 24 automatically. I mean i can edit the ID key in the database manually everytime someone adds info to it , but i prefer it to be automatic.
regards J
hey
So i have a database that has been hammered by spammers in the past and the ID primary key field is auto_incrementing. Due to the spam the ID value has reached 2000 or something daft. The problem is that when users now enter legitamate info. to my database the auto increment continues from 2000 onwards, so the next value would be 2001 - but i want to it to continue from 24 onwards. Am i making sense?!?
My question is how do i get the database to automatically increment the ID field from 24 automatically. I mean i can edit the ID key in the database manually everytime someone adds info to it , but i prefer it to be automatic.
regards J
this question has been dealt with here quite few times --> run a search.
+ why do you wanna start from 24? what's wrong with 2001?
jpmad4it
01-28-2006, 12:37 PM
i am an obsessive complusive so everything has to be right :eek:
I'm a licensed psychologist, so that'll be fixed quickly then:
wanting to have continues PK values, is a real sign of infantility and stamce back to your spreadsheet-period where all visible values needed to be meaningfull.
but in a db, 2001 is just as right as 24 since it has exactly as much functional meaning to a human interface (<-- thats you): nothing at all. It's just an identifier that the rdbm needs, but it shouldn't be of any use to you.
jpmad4it
01-28-2006, 01:01 PM
well at the front end the ID is displayed, and its a bit annoying when they dont run in sequence. Thats all :thumbsup:
why is it annoying?
+ if it should have some meaning (like the order in which something needs to be displayed or so), then you should include an extra column where you store that order in.
jpmad4it
01-28-2006, 01:10 PM
yeah its used to display the entries in order i.e. 1,2,3,4,5,
it HAS to be in order :eek:
if it's just the displaying in that correct order, then you can still use the discontinue PK-values.
Only if you need to be able to reorder the records, then you should include an extra column with the ordervalues, which you then need to maintain in your applicationlayer.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.