Mysql Workbench 无法选择外键 [英] Mysql Workbench Can't Select Foreign Key

查看:58
本文介绍了Mysql Workbench 无法选择外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我检查了很多问题并在谷歌上搜索了很多,但没有一个解决了我的问题..

First of all I've examined a lot of questions and googled it a lot, none of them solved my problem..

我正在使用 Mysql Workbench 6.3 创建我的表.我只使用 gui 而不是单个查询来创建它们.之后,我尝试为 int(11) 列创建一些外键,但 GUI 不允许我这样做.

I'm creating my tables by using Mysql Workbench 6.3. I've created them by using only gui not a single query. After that I've tried to create some foreign keys for int(11) columns but GUI is not allowing me to do so.

这是我的显示创建表'tableName'

CREATE TABLE `item` (
  `id` int(11) NOT NULL,
  `description` varchar(300) NOT NULL,
  `maker` varchar(200) NOT NULL,
  `model` varchar(200) NOT NULL,
  `condition` varchar(200) NOT NULL,
  `locationId` int(11) NOT NULL,
  `categoryId` int(11) NOT NULL,
  `userId` int(11) NOT NULL,
  `lendTermsId` int(11) NOT NULL,
  `itemOptionsId` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id_UNIQUE` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

另一个;

CREATE TABLE `location` (
  `id` int(11) NOT NULL,
  `type` varchar(200) NOT NULL,
  `coordinateLat` varchar(200) NOT NULL,
  `coordinateLong` varchar(45) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id_UNIQUE` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

我正在尝试在 location.iditem.locationId 之间创建一个外键.工作台 GUI 不允许我选择复选框...

I'm trying to create a foreign key between location.id and item.locationId. Workbench GUI is not allowing me to select checkboxes...

正如您从这张图片中看到的,我无法选择复选框或选择组合框值..

As you can see from this image I can't select checkbox or select combobox value..

我可以用查询来管理这个,但有些项目中有很多表,不想用查询来做这一切......有什么我遗漏的吗工作台?

I can manage this with query, but there are a lot of tables in some projects, dont want to do it all with queries... Is there something that I'm missing in workbench ?

提前致谢.

推荐答案

正如 user4115463 所说,这是由 DataType 的差异引起的.确保两个键具有完全相同的数据类型:

As user4115463 said, this is caused by a difference in DataType. Make sure that both keys have the exact same data type:

  • Datatype 字段应包含完全相同的字符串(INTINT(10) 相同)
  • B(是二进制)复选框应该匹配
  • UN(未签名)复选框应匹配

选择复选框时,MySQL Workbench 尝试使用匹配的列填充复选框旁边的下拉列表,如果找不到任何匹配的列,它会决定以静默方式忽略对复选框的点击.

When selecting a checkbox, MySQL Workbench attempts to populate the dropdown next to the checkbox with matching columns, and if it can't find any matching columns, it decides to silently ignore the click on the checkbox instead.

这篇关于Mysql Workbench 无法选择外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆