简体   繁体   English

ERROR 1005(HY000):无法创建表db。#sql-5471_137'(错误号:121)

[英]ERROR 1005 (HY000): Can't create table db.#sql-5471_137' (errno: 121)

 alter table xxx
 add CONSTRAINT `FK_usagehistory_4` FOREIGN KEY (`AuthID`) REFERENCES `licenseattributes` (`AuthID`),
 add CONSTRAINT `FK_usage_5` FOREIGN KEY (`SaaSClientIdentifierID`) REFERENCES `saasclientnodes` (`SaaSClientIdentifierID`),
 add CONSTRAINT `FK_usage_6` FOREIGN KEY (`SaaSServerIdentifierID`) REFERENCES `saasservernodes` (`SaaSServerIdentifierID`),
 add CONSTRAINT `FK_usage_9` FOREIGN KEY (`TenantID`) REFERENCES `tenant` (`TenantID`);

I am getting ERROR "1005 (HY000): Can't create table 'db.#sql-5471_137' (errno: 121)" while runng above command . 我收到ERROR “1005(HY000):无法创建表'db。#sql-5471_137'(错误号:121)”当runng高于命令时。

The error seems to be because you are creating aa foreign key constraint and you need to have a usable index in referencing table and in the referenced table to do so in MySQL. 该错误似乎是因为您正在创建一个外键约束,并且您需要在引用表和引用的表中具有可用的索引以在MySQL中执行此操作。 Probably the index on the referenced table would be missing which you have to create by yourself. 可能缺少必须由您自己创建的引用表上的索引。 The index on the referencing table will be created automatically, so no need to create that. 引用表上的索引将自动创建,因此无需创建该索引。

This problem had been solved. 这个问题已经解决了。 I had changed fk name as its was same as pk. 我改变了fk名称,因为它和pk一样。 That's why I was getting this error. 这就是我收到此错误的原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误1005(HY000):无法创建表db.grades(错误号:150) - ERROR 1005 (HY000): Can't create table 'db.grades' (errno: 150) 错误1005(HY000):无法创建表db.Wine(错误号:150) - Error 1005 (HY000): Can't create table db.Wine (errno: 150) 错误1005(HY000):无法创建表“ db.POSTS”(错误号:150) - ERROR 1005 (HY000): Can't create table 'db.POSTS' (errno: 150) 错误1005(HY000):无法创建表'nortus。#sql-4e0_28'(errno:150) - ERROR 1005 (HY000): Can't create table 'nortus.#sql-4e0_28' (errno: 150) 错误代码1005,SQL状态HY000:无法创建表错误号:150 - Error code 1005, SQL state HY000: Can't create table errno: 150 错误1005(HY000):无法创建表“ shrewd_db.alert_disable_register”(错误号:150) - ERROR 1005 (HY000): Can't create table 'shrewd_db.alert_disable_register' (errno: 150) 外键错误 - 错误 1005 (HY000) … 无法创建表 … `stored_on` (errno: 150) - Foreign Key Error - ERROR 1005 (HY000) … Can't create table … `stored_on` (errno: 150) 错误1005(HY000):无法创建表“ ss.tbl_node”(错误号:150) - ERROR 1005 (HY000): Can't create table 'ss.tbl_node' (errno: 150) ERROR 1005(HY000):无法创建表(错误号:150) - ERROR 1005 (HY000): Can't create table (errno: 150) 错误1005(HY000):无法创建表“ test_schema。#sql-44c_2a”(错误号:150) - ERROR 1005 (HY000): Can't create table 'test_schema.#sql-44c_2a' (errno: 150)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM