In MySQL we might need to auto increment a non primary key field or column in a database table. This might require particularly in cases where we have already set a combination of columns as primary key. So here are steps with images to let you understand how can we make a column as auto increment non primary key column in phpMyAdmin.
Auto increment non primary key column in phpMyAdmin
As you can see in image just above, we have already made ‘user_to‘ and ‘user_by‘ fields as composite primary key. If you don’t know how did we accomplish that? You can read it here. Further we wish to make ‘id‘ fields as auto increment column.
The simplest idea is not to assign ‘A_I‘ to this particular column while table creation in phpMyAdmin, instead first set desired column/s as your primary key as required then do as describe below.
Now it’s time to make a few clicks more. Go to table structure, check the column and click ‘index‘ at right end after columns listing (alternatively this option is also available under more action dropdown). After applying indexing on column, you can change the column properties. In our example we have checked the ‘A_I‘ property for ‘id‘ column by going through change action for this to make it as auto increment non primary key column in phpMyAdmin.