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列与部门表进行绑定。

外键

 三、补充:

猜你喜欢

转载自www.cnblogs.com/AYxing/p/9562550.html