Let's say I have this table, with both columns as primary keys, in mysql workbench and Innodb engine:
+--------+---------+
| grp | name |
+--------+---------+
| fish | lax |
| mammal | dog |
| mammal | bat |
| mammal | whale |
| bird | bat |
| bird | ostrich |
+--------+---------+
How can I add a column, behaving like this with grp column:
+--------+----+---------+
| grp | id | name |
+--------+----+---------+
| fish | 1 | lax |
| mammal | 2 | dog |
| mammal | 2 | cat |
| mammal | 2 | whale |
| bird | 3 | penguin |
| bird | 3 | ostrich |
+--------+----+---------+
Note that the actual table I want to alter is much bigger. Also note this is not what auto incrementing with MyISAM does and not what is asked here(but the answers could be helpful): How to auto increment on different foreign keys?