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)