Page 1 of 1

questions about a priamry key

Posted: Sat 08 Jul 2006 00:48
by ashlar
In one of my tables I have a primary key which is a int. It also is a unsigned int and is set to auto-increment.

If I add lets say 20 records and then delete those 20 records how can I stop or reset it so that it doesn't start the next record on 21? How can I get it to start back at 1?

Posted: Mon 10 Jul 2006 10:05
by Zagawa
Here is the query to reset Auto Increment

Code: Select all

ALTER TABLE tbl_name AUTO_INCREMENT = 0

Re: questions about a priamry key

Posted: Thu 30 Oct 2014 17:19
by Matthew
Is it possible to "reset" or "set" the auto-increment value inside Delphi code?
If so I need help in setting up that code, thanks,

Re: questions about a priamry key

Posted: Fri 31 Oct 2014 08:24
by ViktorV
Here is a code example that demonstrates how to reset auto increment field:

Code: Select all

MyConnection.ExecSQL('ALTER TABLE tbl_name AUTO_INCREMENT = 0');

Re: questions about a priamry key

Posted: Fri 31 Oct 2014 15:20
by Matthew
Thanks!

Re: questions about a priamry key

Posted: Mon 03 Nov 2014 05:55
by ViktorV
Feel free to contact us if you have any further questions.