我已经使用alter table函数将这些外键添加到了表中。
我想将它们添加为一个存储过程,所以当我执行该存储过程时,它将运行并将这些外键添加到我的表中。有什么帮助吗?谢谢
ALTER TABLE [child]
ADD FOREIGN KEY ([mother_father_caregiver_id])
REFERENCES [education] ([education_id])
ALTER TABLE [child]
ADD FOREIGN KEY ([education_id])
REFERENCES [caregiver] ([mother_father_caregiver_id])
ALTER TABLE [child]
ADD FOREIGN KEY ([household_id])
REFERENCES [household] ([household_id])
ALTER TABLE [household]
ADD FOREIGN KEY ([householdage_id])
REFERENCES [householdage] ([householdage_id])
ALTER TABLE [household]
ADD FOREIGN KEY ([livestock_id])
REFERENCES [livestock] ([livestock_id])
ALTER TABLE [household]
ADD FOREIGN KEY ([credit_id])
REFERENCES [credit] ([credit_id])
ALTER TABLE [household]
ADD FOREIGN KEY ([shock_id])
REFERENCES [householdshocks] ([shock_id])