如何将这些组合用于将语句转换为单个alter语句

时间:2014-07-10 19:34:07

标签: sql unique-constraint alter-table

如何将这两个alter语句组合成一个alter语句

ALTER TABLE A
ADD CONSTRAINT  A_FK
  FOREIGN KEY (A_PK_ID)
  REFERENCES C(A_PK_ID);

 ALTER TABLE A
 ADD CONSTRAINT B_FK
  FOREIGN KEY (D_PK_ID)
  REFERENCES E(D_PK_ID);

1 个答案:

答案 0 :(得分:0)

假设MS SQL或MySQL,它就像这样

ALTER TABLE A 
    ADD CONSTRAINT A_FK FOREIGN KEY (A_PK_ID) REFERENCES C(A_PK_ID),
    ADD CONSTRAINT B_FK FOREIGN KEY (D_PK_ID) REFERENCES E(D_PK_ID);