mysql添加外键约束
Posted hoge
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql添加外键约束相关的知识,希望对你有一定的参考价值。
ALTER TABLE scm_material_contract ADD CONSTRAINT material_contract_foreignid FOREIGN KEY(form_id) REFERENCES scm_purchase_contract(contract_id) ALTER TABLE scm_material_contract_add ADD CONSTRAINT material_contract_add_foreignid FOREIGN KEY(form_id) REFERENCES scm_purchase_contract_add(sub_contract_id) ALTER TABLE scm_material_settle_sd ADD CONSTRAINT material_settle_foreignid FOREIGN KEY(form_id) REFERENCES scm_sd_settle(settle_id) ALTER TABLE scm_material_settle_yd ADD CONSTRAINT material_settle_yd_foreignid FOREIGN KEY(form_id) REFERENCES scm_yd_settle(settle_id)
删除外键:
alter table product drop foreign key product_ibfk_1
以上是关于mysql添加外键约束的主要内容,如果未能解决你的问题,请参考以下文章
MySQL 外键约束 - 错误 1452 - 无法添加或更新子行