Search code examples
foreign-keysinnodblinktable

Foreign Key Input error in Link table (Error 1005)


I was trying to input my foreign keys into my Link table all at once. I created all my other tables first then my link table, i added columns to my link table for the foreign keys (that worked). Then i went to insert my foreign keys and it doesn't work (by the way none of my other tables have foreign keys)

it says

#1005 - Can't create table 'waget.#sql-798_842' (errno: 150) (Details...) 

i clicked on details and it comes up with INNODB [ Variables | Buffer Pool | InnoDB Status ] i click on variables it has a question mark next to 3 things Autoextend increment,Buffer pool size,Data home directory

im so lost i just want to be able to create foreign keys please Help My foreign key insert code

use Dbase;
alter table Link
add foreign key (C_id) References C (C_id),
add foreign key (D_id) References D (D_id),
add foreign Key (T_id) References T (T_id),
add foreign Key (B_id) References B (B_id),
add foreign Key (H_id) References H (H_id);

Solution

  • Make sure both collumns are exactly the same: both int or varchar etc., both the same length, both null or not.