Mysql – Modify MySQL foreign key related column without dropping foreign key relation

alter-tableforeign keyMySQL

I need to modify a foreign key related column. When I tried to alter it I got "Error on rename of 'x' to 'y' (errno: 150)" error. So I googled and found foreign key relation is the 'villain'. I dropped the foreign key relation, altered the column and created foreign key relation.

Is there any way to alter foreign key related columns without dropping the relation?

Best Answer

Yeah i think you have a SQL command like :

SET foreign_key_checks = 0;  

which should be session based. Then you set =1 once you're done.