sql语句设置主外键约束

alter table 外键表名 add constraint 约束名称 foreign key(外键字段)  references 主键表名(约束列名) 


如表A中的Ids是主键,要约束表B中的Aid列,那么语句应该是:

alter table B add constraint A_B_Ids foreign key(Aid)  references A(Ids)

posted on 2017-10-23 13:51  小败哥哥。  阅读(227)  评论(0编辑  收藏  举报

导航