Search code examples
mysqlsqlsql-insertcreate-tablealter-table

Modifying a primary key to auto-increment from a set value


I have the following MYSQL statement:

ALTER TABLE students MODIFY studentID INTEGER NOT NULL AUTO_INCREMENT = 20;

StudentID already exists and is primary key. I want to edit it to autoincrement from 20. However, I am getting a red line on the equals sign in mySQL Workbench and the message

= is not valid in this position, expecting EOF.

What am I doing wrong?


Solution

  • I think you want:

    ALTER TABLE students AUTO_INCREMENT = 20;