mysql-数据类型和数据约束
数据类型

数据约束
-
primary key
- 该字段值必须唯一,且不能为空
- 针对主键的字段可以设置自增,auto_increment
-
not null
- 该字段不允许为空值
- 空(null)和''不同,一个没有值为null,一个有值为空字符串
-
unique
- 该字段不允许重复
- 主键只能有一个,唯一的字段可以有多个
-
default
- 该字段没有值时,会使用默认值,若有填写,则显示填写的值
-
foreign key
- 用来维护两个表之间的关联关系

primary key
not null
unique
default
foreign key