Delete all foreign keys in database(MySql)

前端 未结 5 703
广开言路
广开言路 2020-12-15 18:04

I would like to rename a column in a table that is a foreign key to many tables. Apparently this is only possible if you delete the constraints, as I found out in this link.

5条回答
  •  攒了一身酷
    2020-12-15 18:25

    You Can Try using As Like of Following ..

    ALTER TABLE tableName
    DROP FOREIGN KEY fieldName;
    ADD FOREIGN KEY (newForignKeyFieldName);
    

    Also you can try with Reference Key.As like .....

    ALTER TABLE tableName
    DROP FOREIGN KEY fieldName;
    ADD FOREIGN KEY (newForignKeyFieldName)
    REFERENCES anotherTableName(reference_id);
    

提交回复
热议问题