当我试图改变我的桌子时,我得到了这个错误。
Error Code: 1833. Cannot change column 'person_id': used in a foreign key constraint 'fk_fav_food_person_id' of table 'table.favorite_food'
这是我成功运行的 CREATE TABLE STATEMENT。
CREATE TABLE favorite_food(
person_id SMALLINT UNSIGNED,
food VARCHAR(20),
CONSTRAINT pk_favorite_food PRIMARY KEY(person_id,food),
CONSTRAINT fk_fav_food_person_id FOREIGN KEY (person_id)
REFERENCES person (person_id)
);
然后我试图执行这个语句,我得到了上面的错误。
ALTER TABLE person MODIFY person_id SMALLINT UNSIGNED AUTO_INCREMENT;