By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,805 Members | 1,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,805 IT Pros & Developers. It's quick & easy.

autoincrement reset

P: n/a
Hey,
I was wondering if it's possible to reset the "auto_increment" feature in
MySQL. For example, if I have a database with a list that will change
every year (the old list be completely flushed out, deleted) and then I
insert a new list, it will very quickly reach the max INDEX length... Does
it just wrap itself? Is there a way to reset "auto_increment" so that I
can flush all the rows, reset auto_increment, and start from scratch?

(Since it currently isn't very important I just go in with phpMyAdmin, copy
the table structure to a new table, delete the old table, and rename the
new table to what the old table was. Like I said, it's really not that
important of an application, but I like my INDEXes to start from 1 :-) )
-Eric Kincl
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Fri, 21 Nov 2003 18:22:50 +0000, Eric Kincl <Er**@Kincl.net_NO_SPAM_> wrote:
I was wondering if it's possible to reset the "auto_increment" feature in
MySQL.

http://groups.google.com/groups?hl=e....com&frame=off

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #2

P: n/a
Carved in mystic runes upon the very living rock, the last words of Eric
Kincl of comp.lang.php make plain:
length... Does it just wrap itself? Is there a way to reset
"auto_increment" so that I can flush all the rows, reset
auto_increment, and start from scratch?


TRUNCATE [tablename]

will delete all rows and reset the auto_increment column. DELETE FROM will
not reset it.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Jul 17 '05 #3

P: n/a
It's true..do not Delete From

in phpMyAdmin, it's "Empty" to truncate

"Eric Kincl" <Er**@Kincl.net_NO_SPAM_> wrote in message
news:3f******@news.gvsu.edu...
Hey,
I was wondering if it's possible to reset the "auto_increment" feature in
MySQL. For example, if I have a database with a list that will change
every year (the old list be completely flushed out, deleted) and then I
insert a new list, it will very quickly reach the max INDEX length... Does
it just wrap itself? Is there a way to reset "auto_increment" so that I
can flush all the rows, reset auto_increment, and start from scratch?

(Since it currently isn't very important I just go in with phpMyAdmin, copy the table structure to a new table, delete the old table, and rename the
new table to what the old table was. Like I said, it's really not that
important of an application, but I like my INDEXes to start from 1 :-) )
-Eric Kincl

Jul 17 '05 #4

P: n/a
Alan Little <al**@n-o-s-p-a-m-phorm.com> writes:
Carved in mystic runes upon the very living rock, the last words of Eric
Kincl of comp.lang.php make plain:
length... Does it just wrap itself? Is there a way to reset
"auto_increment" so that I can flush all the rows, reset
auto_increment, and start from scratch?


TRUNCATE [tablename]

will delete all rows and reset the auto_increment column. DELETE FROM will
not reset it.


This is true in MySQL 4.x, but in 3.x "DELETE FROM tablename" does
reset the table's Auto_increment value (at least it does on the
3.23.x servers I checked). See this recent thread for examples:

http://groups.google.com/groups?thre...news.skynet.be

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Jul 17 '05 #5

P: n/a
You can reset the Auto_Increment value using ALTER TABLE.

ALTER TABLE [Table Name] AUTO_INCREMENT = 0
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.