By default, when you create a table in MySQL with the AUTO_INCR EMENT column attribute, the count starts from 1. I.e. the first record created will have index 1, the second - 2, etc.
However, sometimes (really rarely) you need to force MySQL to start the AUTO_INCRE MENT count not from 1, but from another number.
The following construction is used for this:
AUTO_INCRE MENT = 100
In the example above we tell the DBMS to start counting from 100, not from 1.
Here's an example of creating a table with auto_increment = 500:
CR EATE TAB LE mytable
(id INT NOT NUL L AUTO_IN CREMENT = 500,
title VARC HAR(255) NOT N ULL DEF AULT ,
address VAR CHAR(255) NOT NU LL DE FAULT , PRIM ARY KEY(id));
Applies to: MySQL 5.x+
Comments