Page 1 of 1

Starting Value for AUTO_INCREMENT

Posted: Tue Jan 07, 2003 2:32 am
by dickey
How do I specify a starting value for use with AUTO_INCREMENT?

example create table script:

CREATE TABLE egtable (
egcolname INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
etc,etc,etc);

In place of starting the numbering at 1, I may like to start the numbering at 10000.

Any advice will be appreciated. Thank you.

-Dickey

Posted: Tue Jan 07, 2003 2:44 am
by Elmseeker

Code: Select all

ALTER TABLE tbl_name AUTO_INCREMENT = 10000;
will start your records at 10000 if you want to start a number other than 10000 simply replace the 10000 in the command with whatever number you wnat to start with.

as a php statement you would do this normally:

Code: Select all

<?
$query = "ALTER TABLE tbl_name AUTO_INCREMENT = 10000";
$result = mysql_query($query);
?>
Enjoy! :)