techfolks mysql tutorials
Mysql

How to Add Column to Mysql Table and Auto Increment with Primary Key


Check below on How to Add a Column to Mysql Table with Auto Increment and Primary Key

You can achieve it by doing Alter Command:

Add Column to Mysql

To Modify Column and add Auto Increment with Primary Key

Query:
ALTER TABLE test MODIFY COLUMN ID INT(10) PRIMARY KEY  auto_increment;

ALTER TABLE users ADD id int NOT NULL AUTO_INCREMENT primary key

To Modify Column Data Type

Query:
ALTER TABLE test MODIFY COLUMN id Float;

To Add Auto Increment and Primary Key Column

Query:
ALTER TABLE con_contacts ADD contact_id int(10) NOT NULL AUTO_INCREMENT primary key;