i m having one table with column (sno,name,addr, age)like that...i set the sno as auto_increment as well as primary key.........i m deleting all the records in the table...if i m inserting the new records the sno was not starting form 1..it's starting from old maximum value that i deleted.....i need to start the auto_increment from 1...can any one plz give the solution for my pbm?..
auto_increment
Collapse
X
-
Tags: None
-
You could DROP the table and recreate it. Should work.Originally posted by rameshkumarci m having one table with column (sno,name,addr, age)like that...i set the sno as auto_increment as well as primary key.........i m deleting all the records in the table...if i m inserting the new records the sno was not starting form 1..it's starting from old maximum value that i deleted.....i need to start the auto_increment from 1...can any one plz give the solution for my pbm?.. -
-
hi...
If u want to delete all the records from the table means, use the command "truncate".
syntax:
truncate table <table_name>;
after truncating the table, if u insert the record, the auto increment value
starts from 1.
Regards,
S.Ashokkumar.Comment
-
hi...
Another one method...
after deleting all the records, use the alter command to reset the auto increment value.
Ex: alter table tbl_xxx auto_increment = 1
Refer this link:
http://www.scriptygodd ess.com/archives/2004/06/24/reset-autoincrement-value-in-mysql-tabl/
Regards,
S.Ashokkumar.Comment
-
Comment