set auto increment value in mysql code example
Example 1: mysql set id auto increment
ALTER TABLE users AUTO_INCREMENT=1001;
Example 2: alter table auto_increment
ALTER TABLE ALLITEMS CHANGE itemid itemid INT(10)AUTO_INCREMENT PRIMARY KEY;
Example 3: auto increment column in mysql query results
SET @auto_increment=0;
SELECT @auto_increment := @auto_increment+1 AS `No`;
Example 4: mysql check auto increment value
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'database_name' AND TABLE_NAME = 'table_name';
Example 5: mysql add auto increment id existing table
ALTER TABLE `users` ADD `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY
Example 6: how to auto increment in sql
CREATE TABLE Persons (
Personid int NOT NULL AUTO_INCREMENT,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
PRIMARY KEY (Personid)
);
INSERT INTO Persons (FirstName,LastName)
VALUES ('Lars','Monsen');