Home » mysql » Give initial auto increment value while table creation

Give initial auto increment value while table creation

When we create a table we can give a auto increment value to a primary key filed.
This field is auto incremented by one for newly inserted value.
To start auto increment from specified number AUTO_INCREMENT = value is used while creating table.

Example:

If you have already created a table and then want to add some initial auto increment value then we have to alter the table as below.
auto increment will start from 1 by default.

To start auto increment from some specified value lets say 100 we use alter table

Syntax

Example

Please follow and like us:
error