auto increment

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
irealms
Forum Contributor
Posts: 215
Joined: Mon Apr 28, 2003 7:10 am
Location: Leeds

auto increment

Post by irealms »

how do i reset the auto increment? at present it enter users with numbers 5 and over . I deleted ones i created to test (ie users 2 to 4). How do i make the id fill in the gaps again?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

If you empty the table, this will reset it. Remember with auto_increment that it's supposed to be a unique identifier for a record so in general you wouldn't want to reuse numbers once a previous record has been deleted.

Mac
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

ALTER TABLE `table_to_use` auto_increment = 1
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

afaik you might increase the auto_increment value of an exisiting table but not decrease it with ALTER TABLE.
Post Reply