Mega Code Archive

 
Categories / MySQL / Data Type
 

For MyISAM tables, you can begin the sequence at a specific initial value n by including an AUTO_INCREMENT = n

clause at the end of the CREATE TABLE statement mysql> mysql> CREATE TABLE t     -> (     ->     id INT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)     -> )     -> AUTO_INCREMENT = 100; Query OK, 0 rows affected (0.01 sec) mysql> mysql> INSERT INTO t (id) VALUES(NULL); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO t (id) VALUES(NULL); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO t (id) VALUES(NULL); Query OK, 1 row affected (0.00 sec) mysql> SELECT id FROM t ORDER BY id; +-----+ | id  | +-----+ | 100 | | 101 | | 102 | +-----+ 3 rows in set (0.00 sec) mysql> mysql> drop table t; Query OK, 0 rows affected (0.00 sec)