How to Set Auto Increment Value In MySQL
- 1). Access your MySQL table and go to the portion where you created your table. It should resemble this:
CREATE TABLE customers (
ident MEDIUMINT NOT NULL,
NAME CHAR(20) DEFAULT '' NOT NULL,
PRIMARY KEY(ident)
); - 2). Insert the text "AUTO_INCREMENT" on the primary key "ident" line. Change the code for your specific table accordingly.
CREATE TABLE customers (
ident MEDIUMINT NOT NULL AUTO_INCREMENT,
NAME CHAR(20) DEFAULT '' NOT NULL,
PRIMARY KEY(ident)
); - 3). Save your database changes. The table will increment the "ident" field automatically.
Source...