13

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
8
  • 2
    Seems to work OK for me. Commented Mar 28, 2014 at 12:17
  • It's working.What error you are facing Commented 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? Commented Mar 28, 2014 at 12:20
  • @patentul check here sqlfiddle.com/#!2/3d392/1 Commented Mar 28, 2014 at 12:22
  • 1
    It is the same previous question from you: Mysql can't create table errno 121 Commented Mar 28, 2014 at 12:28

1 Answer 1

30

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

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

answered Mar 28, 2014 at 12:47
Sign up to request clarification or add additional context in comments.

7 Comments

I did this, none of the constraints resulted in the query are being used in my current query for generating this table
yes I did, One constraint indeed was being used, I replaced that, but it still does not work
Error Code: 1005. Can't create table 'ticket_tool.t_issue' (errno: 121)
Well I did try again, but without success, as I said I replaced the constraints that are used
(+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...
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.