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

相关文章:

  • 2022-12-23
  • 2022-02-02
  • 2022-12-23
  • 2021-12-04
  • 2021-10-04
  • 2021-09-13
  • 2022-12-23
  • 2021-08-30
猜你喜欢
  • 2022-02-13
  • 2021-07-13
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2022-12-23
相关资源
相似解决方案