1.主键约束
2.外键约束
alter table t_book add constraint `fk` foreign key (`bookTypeId`) references t_booktype(`id`);
或者在创表时直接加上
CREATE TABLE t_book(
id int primary key auto_increment,
bookName varchar(20),
author varchar(10),
price decimal(6,2),
bookTypeId int,
constraint `fk` foreign key (`bookTypeId`) references `t_bookType`(`id`)
);
3.检查约束(mysql不支持)
4.默认约束
5.唯一性约束
unique
6.自增列
PS:不知道为啥在写默认约束的时候会出现如下问题,求大佬帮忙,这个是mysql,Navicat。