Connecting Tech Pros Worldwide Forums | Help | Site Map

flusing the database

pradeepjain's Avatar
Needs Regular Fix
 
Join Date: Jul 2007
Location: India
Posts: 407
#1: Oct 7 '08
hii guys,
I am using a table .which i use it for testing for some times .when it goes live i must flush all the data from it so that the Id counter starts from 1.How to do it.....now i drop the table and then create the table again.any other better method.


thanks,
pradeep

Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: Oct 7 '08

re: flusing the database


You can reset the auto increment value for a table using
Expand|Select|Wrap|Line Numbers
  1. alter table tableName auto_increment = 1 
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,754
#3: Oct 7 '08

re: flusing the database


You can use the TRUNCATE syntax.

It basically drops and re-creates the table, which also resets the Auto_Increment value.
Reply