创建外键约束

alter table table_name从表名

add foreign key(从表中需要加的外键列)

references table_name1主表名(主表中的键值)