For MyISAM tables, you can begin the sequence at a specific initial value n by including an AUTO_INCREMENT = n : AUTO_INCREMENT « Data Type « SQL / MySQL

Home
SQL / MySQL
1.Aggregate Functions
2.Backup Load
3.Command MySQL
4.Cursor
5.Data Type
6.Database
7.Date Time
8.Engine
9.Event
10.Flow Control
11.FullText Search
12.Function
13.Geometric
14.I18N
15.Insert Delete Update
16.Join
17.Key
18.Math
19.Procedure Function
20.Regular Expression
21.Select Clause
22.String
23.Table Index
24.Transaction
25.Trigger
26.User Permission
27.View
28.Where Clause
29.XML
SQL / MySQL » Data Type » AUTO_INCREMENT 
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, rows affected (0.01 sec)

mysql>
mysql> INSERT INTO t (idVALUES(NULL);
Query OK, row affected (0.00 sec)

mysql> INSERT INTO t (idVALUES(NULL);
Query OK, row affected (0.00 sec)

mysql> INSERT INTO t (idVALUES(NULL);
Query OK, row affected (0.00 sec)

mysql> SELECT id FROM t ORDER BY id;
+-----+
| id  |
+-----+
100 |
101 |
102 |
+-----+
rows in set (0.00 sec)

mysql>
mysql> drop table t;
Query OK, rows affected (0.00 sec)

   
    
    
    
    
    
    
  
Related examples in the same category
1.Using AUTO_INCREMENT
2.AUTO_INCREMENT Integers
3.Preserve column attributes such as AUTO_INCREMENT and column's default value during table copying.
4.An AUTO_INCREMENT column
5.AUTO_INCREMENT sequences start at one
6.Using an AUTO_INCREMENT Column to Create Multiple Sequences
7.AUTO_INCREMENT column:
8.Not null tinyint and AUTO_INCREMENT
9.MEDIUMINT NOT NULL AUTO_INCREMENT
10.INTEGER UNSIGNED AUTO_INCREMENT
11.Insert value to AUTO_INCREMENT column
12.delete and reinsert value to AUTO_INCREMENT column
13.SET @@AUTO_INCREMENT_OFFSET = 10,@@AUTO_INCREMENT_INCREMENT = 10
14.Set AUTO_INCREMENT value
15.Parameter: INT NOT NULL AUTO_INCREMENT
16.Create a similar table, preserve the auto-incrementing key
17.Defining Auto-Increment Columns
18.If this value is larger than the current sequence counter, subsequent automatically generated values begin with the value plus one
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.