List:General Discussion« Previous MessageNext Message »
From:Shawn Green Date:May 18 2010 5:09pm
Subject:Re: Foreign Key Problem
View as plain text  
Johan De Meersman wrote:
> On Tue, May 18, 2010 at 6:00 PM, Victor Subervi
> <victorsubervi@stripped>wrote:
> 
>>
>> So apparently it didn't like my foreign key. Do I need to do something with
>> the table I'm referencing or what?
>> TIA.
>>
> 
> Well, quickfix is to convert your tables to innoDB, starting with the
> lowest-level (foreign-key only ones) first - I'm not sure what happens if
> you set a referential constraint from an innodb table to a myisam table.
> 
> You can easily convert tables with "alter table *yourtable* engine=innodb;".
> For the tables where you also want to add constraints and/or indices, "alter
> table *yourtable* add constraint *yourconstrainthere* engine=innodb;" does
> the trick in one go.
> 
> 

Both ends of the key need to be InnoDB. The fields also need to match in 
type, nullability, and collation.

For additional details about failed FK attempts, check the error details 
in the SHOW INNODB STATUS report.

-- 
Shawn Green
MySQL Principle Technical Support Engineer
Oracle USA, Inc.
Office: Blountville, TN
Thread
Foreign Key ProblemVictor Subervi18 May
  • Re: Foreign Key ProblemJohan De Meersman18 May
    • Re: Foreign Key ProblemVictor Subervi18 May
      • Re: Foreign Key ProblemJohan De Meersman18 May
        • Re: Foreign Key ProblemShawn Green18 May
          • Re: Foreign Key ProblemVictor Subervi18 May
            • Re: Foreign Key ProblemShawn Green18 May
              • Re: Foreign Key ProblemVictor Subervi19 May
                • Re: Foreign Key ProblemShawn Green19 May
                  • Re: Foreign Key ProblemVictor Subervi19 May
                    • Re: Foreign Key ProblemShawn Green19 May
                      • Re: Foreign Key ProblemVictor Subervi20 May
                        • Re: Foreign Key ProblemVictor Subervi22 May