掌握操作mysql外键简单方法

下文主要给大家带来掌握操作mysql外键简单方法,希望这些内容能够带给大家实际用处,这也是我编辑掌握操作mysql外键简单方法这篇文章的主要目的。好了,废话不多说,大家直接看下文吧。

1.创建外键,关联两个表

create table score(
    id int not null auto_increment,
    subject char(32) not null,
    stu_id int not null,
    primary key(id),
    key fk_stu_key (stu_id),

   constraint fk_stu_key foreign key (stu_id) references student (stu_id));

对于以上关于掌握操作mysql外键简单方法,大家是不是觉得非常有帮助。如果需要了解更多内容,请继续关注我们的行业资讯,相信你会喜欢上这些内容的。