mysql auto  increment field

MySQL auto-increment allows a unique number to be generated when a new record is inserted into a table.

how set the mysql autoincrement field with table column

MySQL autoincrement field syntax:

the following mysql statement defines the "userid" column to be an auto-increment field in the 'users' table:

                           create table      users
                           (
                           
                           userid   int   not null  auto_increment,
                           
                           firstname     varchar(255)    not null,
                           
                           lastname      varchar(255),
                           
                           salary      float
                           
                           primary key(userid)
                           
                           );

the auto_increment keyword to perform an auto-increment feature.

by default, the starting value for auto_increment is 1, and it will increment by 1 for each new record.

if you want to let the auto_increment sequence start with another value, use the following mysql statement :

                          alter  table     users     auto_increment=10