mysql 主键 外键

给已经建好的表添加外键

> alter table 建好的表名 add constraint 外键名(不能与之前起过的名字相同)  foreign key(当前表对应的字段)  references 连接的主表名(主表中的主键名);

Exp:

> alter table chinese add constraint chinese_fk foreign key(No) references students(No);

猜你喜欢

转载自blog.csdn.net/u011378313/article/details/78186927