skip to Main Content

Can not alter table because animal id is foreign key in different table

 ALTER TABLE 'animal' CHANGE 'animal_id' 'animal_id' INT(11) NOT NULL AUTO_INCREMENT;

2

Answers


  1. Because I can’t see your full code, however, I think you can try this:

    ALTER TABLE 'animal' MODIFY 'animal_id INT(11) AUTO_INCREMENT;
    
    Login or Signup to reply.
  2. I think you could do something similar to this response: How to update primary key. When you update the PK, I think you could do something like this response: Alter a MySQL column to be AUTO_INCREMENT.

    But since this response is not best practice, if you don’t need the data in the table, you could drop and then recreate the table.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search