Mysql 无法创建表 errno 121

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22712553/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 20:19:21  来源:igfitidea点击:

Mysql can't create table errno 121

mysql

提问by luca.p.alexandru

Why am I getting this error? I don't have any foreign keys

为什么我收到这个错误?我没有任何外键

drop table if exists t_issue;
SET foreign_key_checks = 0;SET storage_engine=INNODB;
CREATE TABLE `t_issue` (
`id_issue` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`fk_project` int(11) DEFAULT NULL,
`subject` varchar(255) DEFAULT NULL,
`estimated_due_date` date DEFAULT NULL,
`due_date` date DEFAULT NULL,
`done_ratio` int(11) DEFAULT NULL,
`fk_status` int(11) DEFAULT NULL,
`fk_assigned_to` int(11) DEFAULT NULL,
`fk_owner` int(11) DEFAULT NULL
) ENGINE=innodb DEFAULT CHARSET=latin1

回答by jmail

Mysql can't create table errno 121

Mysql 无法创建表 errno 121

You will get this message if you are trying to add a constraint with a name that is already used somewhere else.

如果您尝试使用已在其他地方使用的名称添加约束,您将收到此消息。

To check constraints, use the following SQL query:

要检查约束,请使用以下 SQL 查询:

SELECT
    constraint_name,
    table_name
FROM
    information_schema.table_constraints
WHERE
    constraint_type = 'FOREIGN KEY'
AND table_schema = DATABASE()
ORDER BY
    constraint_name;

Reference: https://dba.stackexchange.com/questions/425/error-creating-foreign-key-from-mysql-workbench

参考:https: //dba.stackexchange.com/questions/425/error-creating-foreign-key-from-mysql-workbench

See also: SQL - error code 1005 with error number 121

另请参阅:SQL - 错误代码 1005,错误编号为 121