Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Posts
    110

    Unanswered: 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

  2. #2
    Join Date
    Oct 2004
    Posts
    6
    You should reference to the column not the index in the foreign key constraint.

  3. #3
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •