Page 1 of 1

auto_increment and the primary key

Posted: Sun Jul 28, 2002 7:15 pm
by cheatboy00
i wanted to know if there is anyway i can reset the autoindex.

see what happened is that i wanted to check to see if my member list worked..(and it did), so i had to add a whole bunch of users.. when i was doen i delted them all...

but i have an autoindex thing that still stays at the 24 mark(well it says thats the next) and even though i have one row and its id is 1...

heres what it says on myphpadmin

Code: Select all

Indexes: 
Keyname  Type     Cardinality    Action       Field 
PRIMARY  PRIMARY  1              Drop  Edit   id  

Row Statistic: 
Statements       Value 
Format           dynamic  
Rows             1  
Row length ø     232  
Row size  ø      2,280 Bytes  
Next Autoindex   24

Posted: Sun Jul 28, 2002 10:55 pm
by fatalcure
if your using phpMyAdmin, just click on the "EMPTY" link above the table, it'll clear out everything in the table and reset the auto increment value :)

Posted: Mon Jul 29, 2002 1:08 pm
by cheatboy00
ya but.....

see i want to know if there is another way to just reset it becasue i want to keep some rows that are in it and i dont want to have to resubmit them....

like take for example there is a table used for comments.... i create a page that allows you to delete the comments.... so whne the person finally deletes some of the comments there will be holes in the id feild.... it would skip numbers... will that hamper the LIMIT $num1,$num2 ...

like what i mean is say $num1 is 0, and $num2 is 20..... then will it get the first 20 rows or will it get up to 20 rows where the id tag is concerned... so something like this....

Code: Select all

id  name  (this is the example for the, 20 rows where id is concerned)
1   sd
3   df
5   867
6   435 
7   657
10 fsdf
15 4353
20 rgg

Posted: Tue Jul 30, 2002 1:36 am
by twigletmac
The whole point of a unique auto-incrementing primary key ID field is that you don't have numbers being reused so the number is the identifier for one record only, even if it has been deleted. If you can't have any gaps in your auto-number field because of the way you've designed your script then you've got a problem and should rewrite your script.

A couple of seconds of testing on your part would have shown you that if you use limit it will return the number of rows specified and won't take into account your ID field at all. The manual may have helped as well...

Mac