MYSQL-主键、外键

一、主键:

create table t4(id int not null auto_increment primary key,
                name char(10),
                num int
                )engine =innodb default charset=utf8;

primary key: 主键
ps: id int not null auto_increment primary key
     将id设置为主键。
主键

 二、外键:

将一张表的某一列,与另外一张表进行绑定的关系叫外键。

上图就是department列与部门表进行绑定。

外键

 三、补充:

posted @ 2018-08-30 20:32  OYxing  阅读(207)  评论(0编辑  收藏  举报