输入banner图图片脚本导航/分类

mysql添加外键语句

 

注意语句中的(`)全部是Esc下面那个键而非单引号!执行语句时是单引号。

 

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`)
);

mysql添加外键语句

标签:pre   arch   mysql   body   log   table   const   约束   bsp