1、双击表格,点击Foreign Keys,建立外键时出现
MySQL Workbench添加外键到EER时出现selected column address must be indexed and be of a compatible type

Foreign key Name:外键名,即别称,可自定义

Referenced Table:从表(外键指向的其它表)

Column:外键列

Referenced Column:从表的外键列
2、双击Referenced Table,然后点击IndexesMySQL Workbench添加外键到EER时出现selected column address must be indexed and be of a compatible type
3、在2处将要Referenced Column打勾即可。即创建了一个索引。

总结:

设置外键的时候需要注意以下几点:

  1. 这个表里面设置的外键必须是另外一个表的主键!
  2. 外键可以不是这个表的主键,但必须和另外一个表的主键相对应(字段的类型和值必须一样)。
  3. 带有主键的那张表称为父表,含外键的是子表,必须先删除外键约束才能删除父表。

相关文章:

  • 2022-12-23
  • 2021-12-16
  • 2022-12-23
  • 2021-11-18
  • 2021-05-17
  • 2022-12-23
  • 2021-06-02
猜你喜欢
  • 2021-08-04
  • 2021-07-05
  • 2021-11-09
  • 2021-12-11
  • 2022-12-23
  • 2021-12-25
相关资源
相似解决方案