- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
所以我正在尝试向我的一个表中添加一个新的外键:
ALTER TABLE `UserTransactions`.`ExpenseBackTransactions`
ADD CONSTRAINT `FK_EBTx_CustomAccountID`
FOREIGN KEY (`CustomAccountID` )
REFERENCES `UserTransactions`.`CustomAccounts` (`CustomAccountID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
ADD INDEX `FK_EBTx_CustomAccountID` (`CustomAccountID` ASC) ;
我不断收到以下错误:
Error Code: 1005
Can't create table './UserTransactions/#sql-187a_29.frm' (errno: 150)
过去我对这个表和其他表进行了相当多的更改,这是我第一次遇到这个问题。有什么想法是什么原因造成的吗?
更新
我的 SHOW INNODB STATUS
错误:
------------------------
LATEST FOREIGN KEY ERROR
------------------------
110525 15:56:36 Error in foreign key constraint of table UserTransactions/#sql-187a_2c:
FOREIGN KEY (`CustomAccountID` )
REFERENCES `UserTransactions`.`CustomAccounts` (`CustomAccountID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION
, ADD INDEX `FK_EBTx_CustomAccountID` (`CustomAccountID` ASC):
Cannot resolve table name close to:
(`CustomAccountID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION
, ADD INDEX `FK_EBTx_CustomAccountID` (`CustomAccountID` ASC)
最佳答案
有一个 nice checklist here .
Below is a running list of known causes that people have reported for the dreaded errno 150:
- The two key fields type and/or size is not an exact match. For example, if one is INT(10) the key field needs to be INT(10) as well and not INT(11) or TINYINT. You may want to confirm the field size using SHOW CREATE TABLE because Query Browser will sometimes visually show just INTEGER for both INT(10) and INT(11). You should also check that one is not SIGNED and the other is UNSIGNED. They both need to be exactly the same. (More about signed vs unsigned here).
- One of the key field that you are trying to reference does not have an index and/or is not a primary key. If one of the fields in the relationship is not a primary key, you must create an index for that field. (thanks to Venkatesh and Erichero and Terminally Incoherent for this tip)
- The foreign key name is a duplicate of an already existing key. Check that the name of your foreign key is unique within your database. Just add a few random characters to the end of your key name to test for this. (Thanks to Niels for this tip)
- One or both of your tables is a MyISAM table. In order to use foreign keys, the tables must both be InnoDB. (Actually, if both tables are MyISAM then you won’t get an error message – it just won’t create the key.) In Query Browser, you can specify the table type.
- You have specified a cascade ON DELETE SET NULL, but the relevant key field is set to NOT NULL. You can fix this by either changing your cascade or setting the field to allow NULL values. (Thanks to Sammy and J Jammin)
- Make sure that the Charset and Collate options are the same both at the table level as well as individual field level for the key columns. (Thanks to FRR for this tip)
- You have a default value (ie default=0) on your foreign key column (Thanks to Omar for the tip)
- One of the fields in the relationship is part of a combination (composite) key and does not have its own individual index. Even though the field has an index as part of the composite key, you must create a separate index for only that key field in order to use it in a constraint. (Thanks to Alex for this tip)
- You have a syntax error in your ALTER statement or you have mistyped one of the field names in the relationship (Thanks to Christian & Mateo for the tip)
- The name of your foreign key exceeds the max length of 64 chars. (Thanks to Nyleta for the tip)
关于mysql - MySQL 中的外键添加失败,错误代码为 1005,编号为 150,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6131421/
我使用 Faker gem 来播种某些数据。我怎样才能设置最大。假公司名称的长度,如何设置假号码的范围? name = Faker::Company.name 这里我想包括最大长度,因为名称对最大长
我试图实现一种方法,在该方法中我创建一个记分板(while 循环)并按某个数字字段(点)对获取的结果进行排序。但我需要实现的是如下 rank----username--point 1st------t
如何在 ListView (vsReport) 中对项目进行编号?现在我有类似的东西: Item := ListView1.Items.Add; Item.Caption :=inttostr(Ite
我正在尝试使用几个按钮在红色和绿色之间切换,我已经浏览了 Jquery 文档,但我似乎无法弄清楚这个。 您可以在我的代码片段中看到,当我单击按钮时,所有按钮都会变成不同的颜色。 而且必须有一种更短的方
是否可以在 GROUP_CONCAT 中进行编号 喜欢 如果,来自 GROUP_CONCAT(empnam SEPARATOR ', ') 我有一套, 我需要 我试过跟随,但没有得到想要的结
在 Linux 中,如何使用用户指定的事件编号创建输入事件接口(interface)并将其映射到特定的设备事件? 我正在使用 gpio-keys 驱动程序来翻译键盘上的按键操作。我定义了要在我的板配置
对于低级应用程序,我在编译时将某种索引定义为一种类型: template class Idx{ using TYPE = T_; static const int IDX = IDX_; }
请问如何设置这种格式的编号: 1) number 1 2) number 2 3) ... 在 HTML 中? 我只找到了一种获取这种格式的方法: 1. number 1 2. number 2 3.
对于我的研究,我需要很少的数据,其中之一是前一次提交的 SHA 编号,即如果我提供特定的提交编号/SHA 编号,我应该能够获得它之前的 SHA 编号。 帮我用 git 命令来获得相同的结果。 最佳答案
我需要询问何时按下数字 1 键,而不是在数字键盘上,而是在 Q 上方的数字 1(试图使这尽可能清楚)。 我已经浏览了 Keys 数组上所有可用的键,但没有一个匹配我正在寻找的键。 有没有办法做到这一点
我正在尝试使用 NAnt 任务设置构建服务器。我有几个想要构建的 Git 存储库,但我在结果的版本控制方面遇到了问题。 如何对库 (dll) 进行版本控制,以便每个构建都使用一个数字来表示每个版本?我
我有一个如下所示的表格: +-------+--------+--------+ | Grp | Party | Member | +-------+--------+--------+ | F
我正在使用 SQL Server 2008。我在查询中返回了这些数据,看起来非常像按 Day 和 ManualOrder 排序的... ID Day ManualOrder Lat L
区域:Silverlight 中的文本框 问题:我需要知道当前编辑的是什么“行号”。 我试过:作为一种解决方法,我尝试使用 textBox.Split("\r") 进行拆分,并计算 Regex 上具有
提前致歉,我不确定如何将 null 值添加到 pandas 数据框,所以我在列表中放置了“无”。我有一个具有以下值的数据框: None, None, 50,60,70,80,90,None,None,
我的应用程序中有一个标签,其中会带有徽章编号,该标签基于3个不同时间发生的3种不同操作。我知道如何使用以下方式设置标签栏标志: [[[[[self tabBarController] tabBar]
有谁知道为什么我们的供应商需要我们的 sku 编号来开发新应用程序? 我们自己将应用程序带入应用程序商店,也许我错了,但构建应用程序或将其上传到商店不需要 sku - 它仅在 iTunes 中连接而不
这个问题已经有答案了: Rationale for Matcher throwing IllegalStateException when no 'matching' method is called
我使用[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]清除徽章编号。它工作正常,但同时删除了远程通知。 还有许多其
我有一个待办事项列表应用程序,我想在图标徽章中显示未完成任务的数量。 我的问题是:我是否应该在用户每次在应用程序中删除/添加新任务时更新徽章编号,还是仅在应用程序即将进入后台模式时更新徽章编号? 最佳
我是一名优秀的程序员,十分优秀!