I\'ve been trying to add auto-increment to one of my columns (basically an ID) but I can\'t find the auto-increment option for my column. Any idea where it is?
The SQL script is correct
ALTER TABLE your_table MODIFY some_column INT NOT NULL AUTO_INCREMENT;
but if you try so make before in the visual mode, with the mysql version 4.7.4, in the struct of the table
Appear when you create the table one option to say "A_I" , if you put your mouse appear message with AUTO_INCREMENT (The version of the foto is in Spanish version)
To use the GUI:
Click the STRUCTURE
tab to see the list of existing fields
To set a field as the PRIMARY FIELD
, click the gold key -- it will turn silver.
To set a field (usually the same field) as auto-increment:
a. Click CHANGE
for that field
b. Look to the far right and checkmark the AI
box
c. Click SAVE
button
A couple quick points based on recent experience:
To the original question, how to select auto-increment with phpmyadmin, it's the small AI check box on the change screen for a field name.
When I tried the "ALTER TABLE tablew_name CHANGE id id BIGINT(20) NOT NULL AUTO_INCREMENT;" solution above, phpmyadmin gave me an error message saying the field had to have a key. I selected a Unique key and the error message went away and the field now auto increments.
You can add it like this
ALTER TABLE your_table
MODIFY some_column INT NOT NULL AUTO_INCREMENT;
This wont work if there are any foreign keys defined, and that is very likely for id fields.
use:
ALTER TABLE tablew_name CHANGE id id BIGINT(20) NOT NULL AUTO_INCREMENT;
instead