Renaming foreign-key columns in MySQL

前端 未结 6 1908
小鲜肉
小鲜肉 2020-11-30 07:20

We\'re trying to rename a column in MySQL (5.1.31, InnoDB) that is a foreign key to another table.

At first, we tried to use Django-South, but came up against a know

6条回答
  •  日久生厌
    2020-11-30 08:00

    In case anyone is looking for the syntax it goes something like this:

    alter table customer_account drop foreign key `FK3FEDF2CC1CD51BAF`; 
    
    alter table customer_account  add constraint `FK3FEDF2CCD115CB1A` foreign key (campaign_id) REFERENCES campaign(id);
    

提交回复
热议问题