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

相关推荐