You usually get this error if your tables use the InnoDB engine. In that case you would have to drop the foreign key, and then do the alter table and drop the column.
But the tricky part is that you can't drop the foreign key using the column name, but instead you would have to find the name used to index it. To find that, issue the following select:
SHOW CREATE TABLE region;
This should show you the name of the index, something like this:
CONSTRAINT region_ibfk_1
FOREIGN
KEY (country_id
) REFERENCES
country
(id
) ON DELETE NO
ACTION ON UPDATE NO ACTION
Now simply issue an:
alter table region drop foreign key
region_ibfk_1
;
And finally an:
alter table region drop column
country_id;
And you are good to go!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…