List:General Discussion« Previous MessageNext Message »
From:<jc Date:May 14 2010 5:17pm
Subject:Can't create foreign key
View as plain text  
I'm trying to create a foreign key by executing the following statement:

ALTER TABLE `cc`.`takenlessons` 

  ADD CONSTRAINT `fk_lessons`

  FOREIGN KEY (`LessonID` )

  REFERENCES `cc`.`lessons` (`id` )

  ON DELETE CASCADE

  ON UPDATE NO ACTION

, ADD INDEX `fk_lessons` (`LessonID` ASC) ;

 

I'm using the RC of MySQL workbench to do this. When I execute this
statement, I get the following error:

Error Code: 1005

Can't create table 'cc.#sql-115c_61' (errno: 121))

 

In the past when I got a similar error, it was because the fields didn't
match exactly. For instance, one may be Int(10) and one Int(11), or one may
be Unsigned, and the other not.  But, in this case, both match exactly.
What other reasons are there for a foreign key creation to fail like that?

 

Thanks,

Jesse



Thread
Can't create foreign keyjc14 May
  • RE: Can't create foreign keyGavin Towey14 May
    • RE: Can't create foreign keyjc14 May
  • Re: Can't create foreign keyCarsten Pedersen14 May
    • RE: Can't create foreign keyjc14 May
      • Re: Can't create foreign keyPrabhat Kumar14 May