...

Auto_increment functionality !!

wap3
11-27-2002, 12:50 PM
Hi

Ok so here is my problem. I have a database with a table named items with a field named Item_ID. This field is set as auto increment. When I enter data into my database however it does not get the last number entered and add one to it, which I thought it would do.

It seems to remember the previous number used. Which is not good because in the meantime if I add and delete records as you do. Then look at the table I end up with gaps in the numers. i.e the Item_ID column will go 12, 13, 26,27, 190 ... you get what I mean.

Its just abit anoying cos to me its a waste. Is there a way to set-up the auto-increment to work like that ??

I have no idea if this is possible but I am just wondering.

Thanks

:thumbsup:

Wichetael
11-27-2002, 01:38 PM
It is normal functionality and to my knowledge you can't use it otherwise.

But why would this be bad? in my opinion it's a good thing. This way you'll never have some old unremoved reference (to some data that was removed) that is pointing to the wrong data in your database...

And I don't think it's that much of a waste really

Ökii
11-28-2002, 09:37 PM
As wichetael said, having it so that it used any missing numbers could easily result in a badly linked site.
If there was a page that linked to show_items?id=77 and you deleted 77, you could either never fill that slot or overwrite it.
If you never used it again, trying to access the page would output your row_not_found message.
If you overwrote it, your visitors might get weird items when looking for normal ones.

I find it best to delete and then recreate all db tables just before going live. This resets auto-inc to zero ready for refilling properly.

You could also count all rows returned and minus that from the highest id number to find how many rows you'd ever deleted.

wap3
11-29-2002, 11:13 AM
Yer i see what your saying but I just didn't expect it to be like that I don't really know why but hey ...

I guessed I thought if you had a limit set on the auto increment field then it would fill up sooner than it needed to.
And because of the way of my pages are set-up and run you wouldn't end up with broken links etc.

Anyway thats that then . . . :cool:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum