Mega Code Archive

 
Categories / MySQL / Table Index
 

Create the table and then set the initial sequence value with ALTER TABLE

mysql> mysql> CREATE TABLE t     -> (id INT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (id)); Query OK, 0 rows affected (0.00 sec) mysql> ALTER TABLE t AUTO_INCREMENT = 100; Query OK, 0 rows affected (0.01 sec) Records: 0  Duplicates: 0  Warnings: 0 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)