模板:
ALTER TABLE 从表 ADD [CONSTRAINT] [外键约束名称] FOREIGN KEY (外键字段名) REFERENCES 主表(主 键字段名) on DELETE (约束)ON UPDATE (约束);
举例:
alter table table1 add constraint waijian1 foreign key(店铺) references table2(店铺) ON DELETE RESTRICT ON UPDATE CASCADE;
模板:
ALTER TABLE 从表 ADD [CONSTRAINT] [外键约束名称] FOREIGN KEY (外键字段名) REFERENCES 主表(主 键字段名) on DELETE (约束)ON UPDATE (约束);
举例:
alter table table1 add constraint waijian1 foreign key(店铺) references table2(店铺) ON DELETE RESTRICT ON UPDATE CASCADE;