Hello,
 
I am having trouble getting the auto_increment function to begin at a set 
value. When I search the docs, I find information like: 
Posted by Michael Craig on September 6 2002 9:51pm       [  
<http://dev.mysql.com/doc/mysql/comment.php?id=1058&action=delete> Delete] [  
<http://dev.mysql.com/doc/mysql/comment.php?id=1058> Edit]    

ALTER TABLE tbl_name AUTO_INCREMENT = 100 
will start your records at 100

ALTER TABLE tbl_name AUTO_INCREMENT = 1000
will start your records at 1000


 

But it does not work for myself. How can I get the auto_increment to begin at a 
set starting point? I know I could insert a bogus record, but it just seems 
sloppy.

Below is the table I continue to work with. It accepts the syntax just fine, 
but as you can tell by the result, it still begins increment at 1.

 
CREATE TABLE CATEGORY (
       cat_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
       parent_id INT,
       visible varchar(1) NOT NULL DEFAULT 'T',
       sort INT,
       cat_name varchar(200)
) TYPE=InnoDB;
ALTER TABLE CATEGORY AUTO_INCREMENT=5000;
 
After an insert I get the folowing:

mysql> insert into category(parent_id, visible, sort, cat_name) values (0, 'T',
1, 'foo');
Query OK, 1 row affected (0.05 sec)
 
mysql> select * from category;
+--------+-----------+---------+------+----------+
| cat_id | parent_id | visible | sort | cat_name |
+--------+-----------+---------+------+----------+
|      1 |         0 | T       |    1 | foo      |
+--------+-----------+---------+------+----------+
1 row in set (0.02 sec)

Thanks,
Scott

Reply via email to