Archive for January 17th, 2008

MySQL (errno: 150)

Just quick note for anyone getting this error. It took me a little while to figure out.
In my case I was trying to add a foreign key with delete on cascade:

ALTER TABLE table_one
ADD CONSTRAINT name_fk FOREIGN KEY (iTable1ID)
EFERENCES table_two(iTable2ID) ON DELETE CASCADE;

And HeidiSQL was spitting out this error msg:

SQL Error: Can’t create table ‘.\database_name\#sql-72c_fb.frm’ (errno: 150)

How to resolve this error:
Make sure your fields datatype match.
They both should have exactly the same datatype and length.
Eg. INT(4) Unsigned isn’t the same as INT(11)

Also make sure if you have data in the table, the foreign keys will not fail.
Eg. If you have an value in one table and not in the other table, it will fail.

This may be common knowledge to most of you but it might come in handy to someone else.

7 comments January 17th, 2008


Calendar

January 2008
M T W T F S S
« Dec   Apr »
 123456
78910111213
14151617181920
21222324252627
28293031  

Posts by Month

Posts by Category