vBulletin

Thank you for visiting. This is our website archive. Please visit our main website by clicking the banner above.
vBulletin FAQ is dedicated to helping the forum owner build, manage and profit from his vBulletin Forum
vBulletin Web Hosting - Free skins and styles for your vBulletin - Search Engine Optimization




How to reset auto_increment back to zero

que
03-22-2006, 03:54 PM
Hi,

I have a table that I'm experimenting with learning. I am constantly deleting all the records from this table and then re-updating with new data. I can't figure out how to reset the auto_incrementing without dropping the table entirely and re-creating it.

Is there a SQL command to reset to 0 each time I delete all the records to start fresh?:confused:

mavahntooth
03-22-2006, 11:00 PM
you mean deleting all the data inside your table?

lilke this?

DELETE * FROM tbl_name

i have really small knowledge about my_sql harhar

noppid
03-23-2006, 10:24 AM
Try dropping and recreating the index. I think the Index tells the query the next auto inc value.

Taylor
03-23-2006, 03:44 PM
Why not just truncate the table instead. That will delete the data and reset the auto_increment counter for the table.

The SQL syntax for TRUNCATE TABLE: TRUNCATE TABLE "table_name"

So, too truncate the table called products simply type:

TRUNCATE TABLE products

see ya :wave:

VBW
03-23-2006, 04:32 PM
ALTER TABLE table_Name AUTO_INCREMENT=1;

that works!

que
03-23-2006, 05:06 PM
Thank's guy's. All good suggestions

I guess I really do not understand how the MySQL auto_increment counter works.


vBulletin

seo book

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum