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 > InnoDB constraint error 150

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-04-04, 02:31
divined divined is offline
Registered User
 
Join Date: Apr 2004
Posts: 110
InnoDB constraint error 150

Hello everybody

I`m trying to create these three InnoDB tables with constraints. The create statements are as shown below :

CREATE TABLE TYPOS(Kwd_Typou INTEGER UNSIGNED AUTO_INCREMENT,
Onomasia VARCHAR(15) NOT NULL,
Kataskeyasths VARCHAR(15),
PRIMARY KEY(Kwd_Typou),
INDEX Kwd_Typou_ind (Kwd_Typou)) TYPE=INNODB;

CREATE TABLE KLINIKH(Kwd_Klinikhs INTEGER UNSIGNED AUTO_INCREMENT,
Onomasia VARCHAR(20),
PRIMARY KEY(Kwd_Klinikhs),
INDEX Kwd_Klinikhs_ind (Kwd_Klinikhs)) TYPE=INNODB;

CREATE TABLE MHXANHMA(Kwd_Mhxanhmatos INTEGER UNSIGNED AUTO_INCREMENT,
Kwd_Klinikhs INTEGER UNSIGNED NOT NULL,
Kwd_Typou INTEGER UNSIGNED NOT NULL,
Onomasia VARCHAR(15) NOT NULL,
Seriakos_Arithmos VARCHAR(15),
INDEX Kwd_Klinikhs_ind (Kwd_Klinikhs),
INDEX Kwd_Typou_ind (Kwd_Typou),
FOREIGN KEY (Kwd_Klinikhs_ind) REFERENCES KLINIKH(Kwd_Klinikhs_ind) ON DELETE SET NULL,
FOREIGN KEY (Kwd_Typou_ind) REFERENCES TYPOS(Kwd_Typou_ind) ON DELETE SET NULL,
PRIMARY KEY(Kwd_Mhxanhmatos)) TYPE = INNODB;

Unfortunately the final create table statement fails with an error code 150. Is there something wrong with my constraints here?

thx, in advance

George Papadopoulos
Reply With Quote
  #2 (permalink)  
Old 03-10-05, 10:31
rladda rladda is offline
Registered User
 
Join Date: Oct 2004
Posts: 6
You should reference to the column not the index in the foreign key constraint.
Reply With Quote
  #3 (permalink)  
Old 03-10-05, 12:42
divined divined is offline
Registered User
 
Join Date: Apr 2004
Posts: 110
Thanks for the help! It`s been quite a while since I had posted the problem. I have found the error myself some time now ,though!

Nonetheless, thanks again!

George Papadopoulos
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