尝试更改表时出现此错误。
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;
4
上面的示例来自《学习SQL,第二版》一书。希望作者Alan Beaulieu做出更正。
—
德米特里(Dmitry)