Monday 11 June 2012

how to add auto increment column in mysql

This alters table "tableName" , and adds a new column "autoIncrementColumn".


ALTER TABLE tableName ADD autoIncrementColumn MEDIUMINT NOT NULL AUTO_INCREMENT KEY

 

 This sets the next auto increment value to 10. Useful if you already have data in the table that you are modifying.

ALTER TABLE tableName AUTO_INCREMENT = 1000;

No comments:

Post a Comment

Note: only a member of this blog may post a comment.