If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > ALTER TABLE with foreign keys not working

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-18-04, 18:59
Axoliien Axoliien is offline
Registered User
 
Join Date: Jul 2003
Posts: 6
ALTER TABLE with foreign keys not working

I have MySQL installed and running, and now am trying to add a foreign key to a table. Every foreign key I have added to all the other tables works, but in this table it simply refuses. I have a table Clients and a table Fees. Clients has a PKEY of ClientID and Fees has a column ClientID that has been indexed. All types are the exact same. When I run the alter table command, I get the error that SHOW INNODB STATUS gives:

No Index Defined on ClientID

040418 18:51:23 Error in foreign key constraint of table wildcatvideoservice/#sql-4f48_653:
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for constraint:
FOREIGN KEY (`ClientID`) REFERENCES `Clients`(`ClientID`) ON UPDATE CASCADE
See http://www.innodb.com/ibman.html for correct foreign key definition.


Please Help!
Reply With Quote
  #2 (permalink)  
Old 04-18-04, 19:47
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
perhaps you could dump out the CREATE TABLE statements so that we could give it a try?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On