MySQL Forums :: InnoDB :: Foreign Key Error 121


Advanced Search

Re: Foreign Key Error 121
Posted by: Jim Maher ()
Date: April 17, 2009 09:54AM

I encountered this problem too, after "simplifying" my naming conventions on an experimental database. Problem occurred many times on many different tables.

Luckily, I found http://forums.mysql.com/read.php?22,33999,249437#msg-249437.

The simplified naming turned out to be the problem. Specifically, two foreign key constraints in two different tables wound up with the same name. Trying to create the second occurence fails.

I actually DID want them to be the same name. It's just a reference check. So, it would be convenient that all checks against table T001 from all other tables would be named something like fk_T001.

But that don't work.

When I renamed the foreign keys to be unique within this database, everything ran fine.

So, I guess the rule is that every foreign key constraint has to be a unique name?


Jim Maher

Options: ReplyQuote


Subject Views Written By Posted
Foreign Key Error 121 20547 Stephen Lynch 04/07/2006 08:35AM
Re: Foreign Key Error 121 5914 Heikki Tuuri 04/09/2006 01:38PM
Re: Foreign Key Error 121 6833 Stephen Lynch 04/10/2006 05:52AM
Re: Foreign Key Error 121 3604 Jim Maher 04/17/2009 09:54AM
Re: Foreign Key Error 121 3990 Heikki Tuuri 04/10/2006 07:06AM
Re: Foreign Key Error 121 3707 Stephen Lynch 04/10/2006 07:48AM
Re: Foreign Key Error 121 3314 Heikki Tuuri 04/10/2006 06:06PM
Re: Foreign Key Error 121 4545 Stephen Lynch 04/11/2006 09:08AM
Re: Foreign Key Error 121 3142 Heikki Tuuri 04/11/2006 02:49PM
Re: Foreign Key Error 121 3402 Nathan Alden 09/17/2007 05:54PM
Re: Foreign Key Error 121 5603 Noga Woronoff 09/26/2007 09:55AM
Re: Foreign Key Error 121 3006 Dave Page 07/07/2008 06:05AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.