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
asked Mar 28, 2014 at 12:14
luca.p.alexandru
1,7706 gold badges24 silver badges47 bronze badges
-
2Seems to work OK for me.Malcolm– Malcolm2014年03月28日 12:17:32 +00:00Commented Mar 28, 2014 at 12:17
-
It's working.What error you are facingNagaraj S– Nagaraj S2014年03月28日 12:17:56 +00:00Commented Mar 28, 2014 at 12:17
-
I changed the name of the table to t_issue1 and the query works for that, for t_issue it doesen't. However I did a "Show tables" but no table named t_issue exists. What could the problem be?luca.p.alexandru– luca.p.alexandru2014年03月28日 12:20:32 +00:00Commented Mar 28, 2014 at 12:20
-
@patentul check here sqlfiddle.com/#!2/3d392/1Nagaraj S– Nagaraj S2014年03月28日 12:22:56 +00:00Commented Mar 28, 2014 at 12:22
-
1It is the same previous question from you: Mysql can't create table errno 121Ravinder Reddy– Ravinder Reddy2014年03月28日 12:28:12 +00:00Commented Mar 28, 2014 at 12:28
1 Answer 1
Mysql can't create table 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:
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
answered Mar 28, 2014 at 12:47
jmail
6,1503 gold badges23 silver badges35 bronze badges
Sign up to request clarification or add additional context in comments.
7 Comments
luca.p.alexandru
I did this, none of the constraints resulted in the query are being used in my current query for generating this table
luca.p.alexandru
yes I did, One constraint indeed was being used, I replaced that, but it still does not work
luca.p.alexandru
Error Code: 1005. Can't create table 'ticket_tool.t_issue' (errno: 121)
luca.p.alexandru
Well I did try again, but without success, as I said I replaced the constraints that are used
jmail
(+1) for useful question, because Most of the person(stack over flowers) don't know this question, so, get the +1 for the useful question...
|
lang-sql