日期:2014-05-16 浏览次数:20459 次
alter table 子表 add constraint 外键约束名 foreign key (子表外键字段) references 父表(父表主键字段)
--添加外键并且会添加该外键字段
ALTER TABLE customerformentries ADD CONSTRAINT FOREIGN operationroleid REFERENCES operationroles(ID) ;?
--仅仅只添加外键
ALTER TABLE customerformentries ADD CONSTRAINT fk_cfe_operationroleid FOREIGN KEY (operationroleid) REFERENCES operationroles(ID) ;on update cascade /on delete cascade?
on update cascade是级联更新的意思,on delete cascade是级联删除的意思,意思就是说当你更新或删除主键表,那外见表也会跟随一起更新或删除
?