文章内容

2018/8/14 16:13:14,作 者: 黄兵

Cannot change column 'b_name': used in a foreign key constraint 'material_product_ibfk_1' of table 'Material_Development.material_product'

最近修改数据库编码格式的时候,参考了这篇文章:1366, "Incorrect string value: '\\xE9\\xBB\\x84\\xE5\\x85\\xB5' for column 'fullname' at row 1",结果报如下错误:

Cannot change column 'b_name': used in a foreign key constraint 'material_product_ibfk_1' of table 'Material_Development.material_product'


出错原因:

无法改变b_name,b_name字段是一个外键。


解决方案:

1、首先可以禁用约束检查,运行ALTER语句,然后再次启用约束检查器:

SET foreign_key_checks = 0;

alter table material_brand convert to character set utf8mb4 collate utf8mb4_bin;

SET foreign_key_checks = 1;


参考资料:

How to get past the following "Cannot change column 'xxx': used in a foreign key constraint"


黄兵个人博客原创。

转载请注明出处:黄兵个人博客  - Cannot change column 'b_name': used in a foreign key constraint 'material_product_ibfk_1' of table 'Material_Development.material_product'

分享到:

发表评论

评论列表